mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Working on gateway fees
This commit is contained in:
parent
7d0ec404da
commit
d1b8d771f6
@ -500,7 +500,7 @@ class AccountController extends BaseController
|
|||||||
'title' => trans('texts.online_payments'),
|
'title' => trans('texts.online_payments'),
|
||||||
'tokenBillingOptions' => $tokenBillingOptions,
|
'tokenBillingOptions' => $tokenBillingOptions,
|
||||||
'currency' => Utils::getFromCache(Session::get(SESSION_CURRENCY, DEFAULT_CURRENCY), 'currencies'),
|
'currency' => Utils::getFromCache(Session::get(SESSION_CURRENCY, DEFAULT_CURRENCY), 'currencies'),
|
||||||
'taxRates' => TaxRate::scope()->whereIsInclusive(false)->get(['id', 'name', 'rate']),
|
'taxRates' => TaxRate::scope()->whereIsInclusive(false)->orderBy('rate')->get(['public_id', 'name', 'rate']),
|
||||||
'account' => $account,
|
'account' => $account,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
@ -189,6 +189,14 @@ class Account extends Eloquent
|
|||||||
return $this->hasMany('App\Models\AccountGateway');
|
return $this->hasMany('App\Models\AccountGateway');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||||
|
*/
|
||||||
|
public function account_gateway_settings()
|
||||||
|
{
|
||||||
|
return $this->hasMany('App\Models\AccountGatewaySettings');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||||
*/
|
*/
|
||||||
|
@ -171,10 +171,9 @@ class AccountGatewayDatatable extends EntityDatatable
|
|||||||
$accountGatewaySettings = AccountGatewaySettings::scope()
|
$accountGatewaySettings = AccountGatewaySettings::scope()
|
||||||
->where('account_gateway_settings.gateway_type_id', '=', $gatewayType->id)
|
->where('account_gateway_settings.gateway_type_id', '=', $gatewayType->id)
|
||||||
->first();
|
->first();
|
||||||
$min = $accountGatewaySettings && $accountGatewaySettings->min_limit !== null ? $accountGatewaySettings->min_limit : 'null';
|
//$min = $accountGatewaySettings && $accountGatewaySettings->min_limit !== null ? $accountGatewaySettings->min_limit : 'null';
|
||||||
$max = $accountGatewaySettings && $accountGatewaySettings->max_limit !== null ? $accountGatewaySettings->max_limit : 'null';
|
//$max = $accountGatewaySettings && $accountGatewaySettings->max_limit !== null ? $accountGatewaySettings->max_limit : 'null';
|
||||||
|
return "javascript:showLimitsModal('{$gatewayType->name}', {$gatewayType->id})";
|
||||||
return "javascript:showLimitsModal('{$gatewayType->name}', {$gatewayType->id}, $min, $max)";
|
|
||||||
},
|
},
|
||||||
function ($model) use ($gatewayType) {
|
function ($model) use ($gatewayType) {
|
||||||
// Only show this action if the given gateway supports this gateway type
|
// Only show this action if the given gateway supports this gateway type
|
||||||
|
@ -64,7 +64,7 @@ You can install PhantomJS to generate the PDF locally, to enable it add ``PHANTO
|
|||||||
Custom Fonts
|
Custom Fonts
|
||||||
""""""""""""
|
""""""""""""
|
||||||
|
|
||||||
Follow these steps to add custom ttf fonts: ie, Google fonts
|
Follow these steps to add custom ttf fonts: ie, `Google fonts <https://www.google.com/get/noto/>`_
|
||||||
|
|
||||||
- Create a new folder in ``public/fonts/invoice-fonts/`` and copy over the ttf files
|
- Create a new folder in ``public/fonts/invoice-fonts/`` and copy over the ttf files
|
||||||
- Run ``grunt dump_dir``
|
- Run ``grunt dump_dir``
|
||||||
|
@ -117,7 +117,7 @@
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div role="tabpanel" class="tab-pane active" id="fees">
|
<div role="tabpanel" class="tab-pane" id="fees">
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
|
|
||||||
{!! Former::text('fee_amount')
|
{!! Former::text('fee_amount')
|
||||||
@ -138,23 +138,24 @@
|
|||||||
->onchange('onTaxRateChange(1)')
|
->onchange('onTaxRateChange(1)')
|
||||||
->addOption('', '')
|
->addOption('', '')
|
||||||
->label(trans('texts.tax_rate'))
|
->label(trans('texts.tax_rate'))
|
||||||
->fromQuery($taxRates, function($model) { return $model->name . ' ' . $model->rate . '%'; }, 'id') !!}
|
->fromQuery($taxRates, function($model) { return $model->name . ' ' . $model->rate . '%'; }, 'public_id') !!}
|
||||||
|
|
||||||
{!! Former::text('fee_tax_name1') !!}
|
|
||||||
{!! Former::text('fee_tax_rate1') !!}
|
|
||||||
|
|
||||||
@if ($account->enable_second_tax_rate)
|
@if ($account->enable_second_tax_rate)
|
||||||
{!! Former::select('tax_rate2')
|
{!! Former::select('tax_rate2')
|
||||||
->onchange('onTaxRateChange(2)')
|
->onchange('onTaxRateChange(2)')
|
||||||
->addOption('', '')
|
->addOption('', '')
|
||||||
->label(trans('texts.tax_rate'))
|
->label(trans('texts.tax_rate'))
|
||||||
->fromQuery($taxRates, function($model) { return $model->name . ' ' . $model->rate . '%'; }, 'id') !!}
|
->fromQuery($taxRates, function($model) { return $model->name . ' ' . $model->rate . '%'; }, 'public_id') !!}
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
|
@endif
|
||||||
|
|
||||||
|
<div style="display:none">
|
||||||
|
{!! Former::text('fee_tax_name1') !!}
|
||||||
|
{!! Former::text('fee_tax_rate1') !!}
|
||||||
{!! Former::text('fee_tax_name2') !!}
|
{!! Former::text('fee_tax_name2') !!}
|
||||||
{!! Former::text('fee_tax_rate2') !!}
|
{!! Former::text('fee_tax_rate2') !!}
|
||||||
|
</div>
|
||||||
@endif
|
|
||||||
|
|
||||||
<br/><div id="feeSample" class="help-block"></div>
|
<br/><div id="feeSample" class="help-block"></div>
|
||||||
|
|
||||||
@ -185,14 +186,26 @@
|
|||||||
window.onDatatableReady = actionListHandler;
|
window.onDatatableReady = actionListHandler;
|
||||||
|
|
||||||
var taxRates = {!! $taxRates !!};
|
var taxRates = {!! $taxRates !!};
|
||||||
|
var taxRatesMap = {};
|
||||||
|
for (var i=0; i<taxRates.length; i++) {
|
||||||
|
var taxRate = taxRates[i];
|
||||||
|
taxRatesMap[taxRate.public_id] = taxRate;
|
||||||
|
}
|
||||||
|
var gatewaySettings = {};
|
||||||
|
|
||||||
function showLimitsModal(gateway_type, gateway_type_id, min_limit, max_limit) {
|
@foreach ($account->account_gateway_settings as $setting)
|
||||||
|
gatewaySettings[{{ $setting->gateway_type_id }}] = {!! $setting !!};
|
||||||
|
@endforeach
|
||||||
|
|
||||||
|
//function showLimitsModal(gateway_type, gateway_type_id, min_limit, max_limit, fee_amount, fee_percent, fee_tax_name1, fee_tax_rate1, fee_tax_name2, fee_tax_rate2) {
|
||||||
|
function showLimitsModal(gateway_type, gateway_type_id) {
|
||||||
|
var settings = gatewaySettings[gateway_type_id];
|
||||||
var modalLabel = {!! json_encode(trans('texts.set_limits_fees')) !!};
|
var modalLabel = {!! json_encode(trans('texts.set_limits_fees')) !!};
|
||||||
$('#paymentLimitsModalLabel').text(modalLabel.replace(':gateway_type', gateway_type));
|
$('#paymentLimitsModalLabel').text(modalLabel.replace(':gateway_type', gateway_type));
|
||||||
|
|
||||||
limitsSlider.noUiSlider.set([min_limit !== null ? min_limit : 0, max_limit !== null ? max_limit : 100000]);
|
limitsSlider.noUiSlider.set([settings.min_limit !== null ? settings.min_limit : 0, settings.max_limit !== null ? settings.max_limit : 100000]);
|
||||||
|
|
||||||
if (min_limit !== null) {
|
if (settings.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 {
|
||||||
@ -200,7 +213,7 @@
|
|||||||
$('#payment-limit-min-enable').prop('checked', false);
|
$('#payment-limit-min-enable').prop('checked', false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (max_limit !== null) {
|
if (settings.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 {
|
||||||
@ -209,6 +222,10 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
$('#payment-limit-gateway-type').val(gateway_type_id);
|
$('#payment-limit-gateway-type').val(gateway_type_id);
|
||||||
|
$('#fee_amount').val(settings.fee_amount);
|
||||||
|
$('#fee_percent').val(settings.fee_percent);
|
||||||
|
setTaxRate(1, settings.fee_tax_name1, settings.fee_tax_rate1);
|
||||||
|
setTaxRate(2, settings.fee_tax_name2, settings.fee_tax_rate2);
|
||||||
|
|
||||||
$('#paymentLimitsModal').modal('show');
|
$('#paymentLimitsModal').modal('show');
|
||||||
}
|
}
|
||||||
@ -274,13 +291,13 @@
|
|||||||
|
|
||||||
var taxRate1 = $('#tax_rate1').val();
|
var taxRate1 = $('#tax_rate1').val();
|
||||||
if (taxRate1) {
|
if (taxRate1) {
|
||||||
taxRate1 = NINJA.parseFloat(taxRates[taxRate1-1].rate);
|
taxRate1 = NINJA.parseFloat(taxRatesMap[taxRate1].rate);
|
||||||
total += subtotal * taxRate1 / 100;
|
total += subtotal * taxRate1 / 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
var taxRate2 = NINJA.parseFloat($('#tax_rate2').val());
|
var taxRate2 = NINJA.parseFloat($('#tax_rate2').val());
|
||||||
if (taxRate2) {
|
if (taxRate2) {
|
||||||
taxRate2 = NINJA.parseFloat(taxRates[taxRate2-1].rate);
|
taxRate2 = NINJA.parseFloat(taxRatesMap[taxRate2].rate);
|
||||||
total += subtotal * taxRate2 / 100;
|
total += subtotal * taxRate2 / 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -293,7 +310,7 @@
|
|||||||
function onTaxRateChange(instance) {
|
function onTaxRateChange(instance) {
|
||||||
var taxRate = $('#tax_rate' + instance).val();
|
var taxRate = $('#tax_rate' + instance).val();
|
||||||
if (taxRate) {
|
if (taxRate) {
|
||||||
taxRate = taxRates[taxRate-1];
|
taxRate = taxRatesMap[taxRate];
|
||||||
}
|
}
|
||||||
|
|
||||||
$('#fee_tax_name' + instance).val(taxRate ? taxRate.name : '');
|
$('#fee_tax_name' + instance).val(taxRate ? taxRate.name : '');
|
||||||
@ -302,10 +319,30 @@
|
|||||||
updateFeeSample();
|
updateFeeSample();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setTaxRate(instance, name, rate) {
|
||||||
|
if (!name || !rate) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var found = false;
|
||||||
|
for (var i=0; i<taxRates.length; i++) {
|
||||||
|
var taxRate = taxRates[i];
|
||||||
|
if (taxRate.name == name && taxRate.rate == rate) {
|
||||||
|
$('#tax_rate' + instance).val(taxRate.public_id);
|
||||||
|
found = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!found) {
|
||||||
|
taxRatesMap[0] = {name:name, rate:rate, public_id:0};
|
||||||
|
$('#tax_rate' + instance).append(new Option(name + ' ' + rate + '%', 0)).val(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
onTaxRateChange(instance);
|
||||||
|
}
|
||||||
|
|
||||||
@if (Utils::isNinja())
|
@if (Utils::isNinja())
|
||||||
updateFeeSample();
|
updateFeeSample();
|
||||||
$(function() {
|
$(function() {
|
||||||
javascript:showLimitsModal('Credit Card', 1, null, null);
|
javascript:showLimitsModal('Credit Card', 1);
|
||||||
});
|
});
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user