2015-10-14 16:15:39 +02:00
|
|
|
@extends('header')
|
2015-03-16 22:45:25 +01:00
|
|
|
|
2016-06-09 09:56:22 +02:00
|
|
|
@section('content')
|
|
|
|
@parent
|
2015-10-14 16:15:39 +02:00
|
|
|
@include('accounts.nav', ['selected' => ACCOUNT_PAYMENTS])
|
2017-03-14 14:18:31 +01:00
|
|
|
@include('money_script')
|
2015-03-16 22:45:25 +01:00
|
|
|
|
2016-05-25 16:36:40 +02:00
|
|
|
{!! Former::open()->addClass('warn-on-exit') !!}
|
|
|
|
{!! Former::populateField('token_billing_type_id', $account->token_billing_type_id) !!}
|
|
|
|
{!! Former::populateField('auto_bill_on_due_date', $account->auto_bill_on_due_date) !!}
|
2017-03-26 09:37:32 +02:00
|
|
|
{!! Former::populateField('gateway_fee_enabled', $account->gateway_fee_enabled) !!}
|
2018-03-25 14:05:24 +02:00
|
|
|
{!! Former::populateField('send_item_details', $account->send_item_details) !!}
|
2016-05-25 16:36:40 +02:00
|
|
|
|
|
|
|
<div class="panel panel-default">
|
|
|
|
<div class="panel-heading">
|
|
|
|
<h3 class="panel-title">{!! trans('texts.payment_settings') !!}</h3>
|
|
|
|
</div>
|
|
|
|
<div class="panel-body">
|
|
|
|
{!! Former::select('token_billing_type_id')
|
|
|
|
->options($tokenBillingOptions)
|
|
|
|
->help(trans('texts.token_billing_help')) !!}
|
2017-03-24 15:14:39 +01:00
|
|
|
|
2016-05-25 21:55:23 +02:00
|
|
|
{!! Former::inline_radios('auto_bill_on_due_date')
|
2016-05-25 16:36:40 +02:00
|
|
|
->label(trans('texts.auto_bill'))
|
2016-05-25 21:55:23 +02:00
|
|
|
->radios([
|
|
|
|
trans('texts.on_send_date') => ['value'=>0, 'name'=>'auto_bill_on_due_date'],
|
|
|
|
trans('texts.on_due_date') => ['value'=>1, 'name'=>'auto_bill_on_due_date'],
|
|
|
|
])->help(trans('texts.auto_bill_ach_date_help')) !!}
|
2017-03-24 14:21:35 +01:00
|
|
|
|
2017-03-26 09:37:32 +02:00
|
|
|
{!! Former::checkbox('gateway_fee_enabled')
|
2017-03-24 14:21:35 +01:00
|
|
|
->help('gateway_fees_help')
|
|
|
|
->label('gateway_fees')
|
|
|
|
->text('enable')
|
2017-03-26 09:37:32 +02:00
|
|
|
->value(1) !!}
|
2018-03-25 14:05:24 +02:00
|
|
|
|
|
|
|
{!! Former::checkbox('send_item_details')
|
|
|
|
->help('send_item_details_help')
|
|
|
|
->label('item_details')
|
|
|
|
->text('enable')
|
|
|
|
->value(1) !!}
|
|
|
|
|
2017-03-16 15:24:50 +01:00
|
|
|
<br/>
|
2017-03-19 14:31:25 +01:00
|
|
|
{!! Former::actions( Button::success(trans('texts.save'))->withAttributes(['id' => 'formSave'])->submit()->appendIcon(Icon::create('floppy-disk')) ) !!}
|
2016-05-25 16:36:40 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
2017-04-19 19:46:11 +02:00
|
|
|
|
2016-05-25 16:36:40 +02:00
|
|
|
{!! Former::close() !!}
|
2016-07-21 14:35:23 +02:00
|
|
|
|
2015-03-16 22:45:25 +01:00
|
|
|
@if ($showAdd)
|
2015-04-27 14:28:40 +02:00
|
|
|
{!! Button::primary(trans('texts.add_gateway'))
|
2015-05-19 21:14:00 +02:00
|
|
|
->asLinkTo(URL::to('/gateways/create'))
|
2015-04-01 21:57:02 +02:00
|
|
|
->withAttributes(['class' => 'pull-right'])
|
2015-04-15 18:35:41 +02:00
|
|
|
->appendIcon(Icon::create('plus-sign')) !!}
|
2015-03-16 22:45:25 +01:00
|
|
|
@endif
|
|
|
|
|
2015-11-05 23:37:04 +01:00
|
|
|
@include('partials.bulk_form', ['entityType' => ENTITY_ACCOUNT_GATEWAY])
|
|
|
|
|
2015-04-01 21:57:02 +02:00
|
|
|
{!! Datatable::table()
|
2015-03-16 22:45:25 +01:00
|
|
|
->addColumn(
|
2017-03-16 21:56:13 +01:00
|
|
|
trans('texts.gateway'),
|
2017-03-14 14:18:31 +01:00
|
|
|
trans('texts.limits'),
|
|
|
|
trans('texts.fees'),
|
2015-03-16 22:45:25 +01:00
|
|
|
trans('texts.action'))
|
|
|
|
->setUrl(url('api/gateways/'))
|
|
|
|
->setOptions('sPaginationType', 'bootstrap')
|
|
|
|
->setOptions('bFilter', false)
|
|
|
|
->setOptions('bAutoWidth', false)
|
2017-03-19 15:35:03 +01:00
|
|
|
->setOptions('aoColumns', [[ "sWidth"=> "20%" ], ["sWidth"=> "20%"], ["sWidth"=> "30%"], ["sWidth"=> "20%"]])
|
2017-03-14 14:18:31 +01:00
|
|
|
->setOptions('aoColumnDefs', [['bSortable'=>false, 'aTargets'=>[1, 2, 3]]])
|
2015-04-01 21:57:02 +02:00
|
|
|
->render('datatable') !!}
|
2015-03-16 22:45:25 +01:00
|
|
|
|
2016-09-15 12:41:09 +02:00
|
|
|
{!! Former::open( 'settings/payment_gateway_limits') !!}
|
2017-03-16 15:03:17 +01:00
|
|
|
|
2016-09-15 12:41:09 +02:00
|
|
|
<div class="modal fade" id="paymentLimitsModal" tabindex="-1" role="dialog"
|
|
|
|
aria-labelledby="paymentLimitsModalLabel"
|
|
|
|
aria-hidden="true">
|
|
|
|
<div class="modal-dialog" style="min-width:150px">
|
|
|
|
<div class="modal-content">
|
|
|
|
<div class="modal-header">
|
|
|
|
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
|
|
|
<h4 class="modal-title" id="paymentLimitsModalLabel"></h4>
|
|
|
|
</div>
|
|
|
|
|
2017-03-14 14:18:31 +01:00
|
|
|
<div class="container" style="width: 100%; padding-bottom: 2px !important">
|
2017-03-26 10:45:17 +02:00
|
|
|
<div class="panel panel-default">
|
2017-02-18 22:20:03 +01:00
|
|
|
<div class="panel-body">
|
2017-03-14 14:18:31 +01:00
|
|
|
<div role="tabpanel">
|
|
|
|
<ul class="nav nav-tabs" role="tablist" style="border: none">
|
|
|
|
<li role="presentation" class="active">
|
|
|
|
<a href="#limits" aria-controls="limits" role="tab" data-toggle="tab">{{ trans('texts.limits') }}</a>
|
|
|
|
</li>
|
|
|
|
<li role="presentation">
|
|
|
|
<a href="#fees" aria-controls="fees" role="tab" data-toggle="tab">{{ trans('texts.fees') }}</a>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
<div class="tab-content">
|
|
|
|
<div role="tabpanel" class="tab-pane active" id="limits">
|
|
|
|
<div class="panel-body"><br/>
|
|
|
|
<div class="row" style="text-align:center">
|
|
|
|
<div class="col-xs-12">
|
|
|
|
<div id="payment-limits-slider"></div>
|
|
|
|
</div>
|
|
|
|
</div><br/>
|
|
|
|
<div class="row">
|
|
|
|
<div class="col-md-6">
|
|
|
|
<div id="payment-limit-min-container">
|
|
|
|
<label for="payment-limit-min">{{ trans('texts.min') }}</label><br>
|
|
|
|
<div class="input-group" style="padding-bottom:8px">
|
|
|
|
<span class="input-group-addon">{{ $currency->symbol }}</span>
|
|
|
|
<input type="number" class="form-control" min="0" id="payment-limit-min"
|
|
|
|
name="limit_min">
|
|
|
|
</div>
|
|
|
|
<label><input type="checkbox" id="payment-limit-min-enable"
|
|
|
|
name="limit_min_enable"> {{ trans('texts.enable_min') }}</label>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="col-md-6">
|
|
|
|
<div id="payment-limit-max-container">
|
|
|
|
<label for="payment-limit-max">{{ trans('texts.max') }}</label><br>
|
|
|
|
|
|
|
|
<div class="input-group" style="padding-bottom:8px">
|
|
|
|
<span class="input-group-addon">{{ $currency->symbol }}</span>
|
|
|
|
<input type="number" class="form-control" min="0" id="payment-limit-max"
|
|
|
|
name="limit_max">
|
|
|
|
</div>
|
|
|
|
<label><input type="checkbox" id="payment-limit-max-enable"
|
|
|
|
name="limit_max_enable"> {{ trans('texts.enable_max') }}</label>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
2017-03-14 16:45:36 +01:00
|
|
|
<div role="tabpanel" class="tab-pane" id="fees">
|
2017-03-24 14:28:31 +01:00
|
|
|
<div id="feesDisabled" class="panel-body" style="display:none">
|
2017-09-06 15:59:06 +02:00
|
|
|
<center style="font-size:16px;color:#888888;">
|
|
|
|
{{ trans('texts.fees_disabled') }}
|
|
|
|
</center>
|
2017-03-24 14:28:31 +01:00
|
|
|
</div>
|
|
|
|
<div id="feesEnabled" class="panel-body">
|
2017-03-14 14:18:31 +01:00
|
|
|
|
|
|
|
{!! Former::text('fee_amount')
|
2017-03-16 15:03:17 +01:00
|
|
|
->label('amount')
|
2017-03-14 14:18:31 +01:00
|
|
|
->onchange('updateFeeSample()')
|
|
|
|
->type('number')
|
|
|
|
->step('any') !!}
|
|
|
|
|
|
|
|
{!! Former::text('fee_percent')
|
2017-03-16 15:03:17 +01:00
|
|
|
->label('percent')
|
2017-03-14 14:18:31 +01:00
|
|
|
->onchange('updateFeeSample()')
|
|
|
|
->type('number')
|
|
|
|
->step('any')
|
|
|
|
->append('%') !!}
|
|
|
|
|
2019-01-30 12:00:26 +01:00
|
|
|
{!! Former::checkbox('adjust_fee_percent')
|
|
|
|
->label(' ')
|
|
|
|
->text(trans('texts.adjust_fee_percent_help'))
|
|
|
|
->onchange('updateFeeSample()')
|
|
|
|
->value(1) !!}
|
|
|
|
|
|
|
|
{!! Former::text('fee_cap')
|
|
|
|
->label('maximum')
|
|
|
|
->onchange('updateFeeSample()')
|
|
|
|
->type('number')
|
|
|
|
->step('any') !!}
|
|
|
|
|
2017-03-14 14:18:31 +01:00
|
|
|
@if ($account->invoice_item_taxes)
|
|
|
|
{!! Former::select('tax_rate1')
|
|
|
|
->onchange('onTaxRateChange(1)')
|
|
|
|
->addOption('', '')
|
|
|
|
->label(trans('texts.tax_rate'))
|
2017-03-19 14:31:25 +01:00
|
|
|
->fromQuery($taxRates, function($model) { return $model->name . ': ' . $model->rate . '%'; }, 'public_id') !!}
|
2017-03-14 14:18:31 +01:00
|
|
|
|
|
|
|
@if ($account->enable_second_tax_rate)
|
|
|
|
{!! Former::select('tax_rate2')
|
|
|
|
->onchange('onTaxRateChange(2)')
|
|
|
|
->addOption('', '')
|
|
|
|
->label(trans('texts.tax_rate'))
|
2017-03-19 14:31:25 +01:00
|
|
|
->fromQuery($taxRates, function($model) { return $model->name . ': ' . $model->rate . '%'; }, 'public_id') !!}
|
2017-03-14 14:18:31 +01:00
|
|
|
@endif
|
|
|
|
|
2017-03-14 16:45:36 +01:00
|
|
|
@endif
|
|
|
|
|
|
|
|
<div style="display:none">
|
|
|
|
{!! Former::text('fee_tax_name1') !!}
|
|
|
|
{!! Former::text('fee_tax_rate1') !!}
|
2017-03-14 14:18:31 +01:00
|
|
|
{!! Former::text('fee_tax_name2') !!}
|
|
|
|
{!! Former::text('fee_tax_rate2') !!}
|
2017-03-17 11:13:27 +01:00
|
|
|
</div><br/>
|
2017-03-14 14:18:31 +01:00
|
|
|
|
2017-03-17 11:13:27 +01:00
|
|
|
<div class="help-block">
|
|
|
|
<span id="feeSample"></span>
|
2017-03-26 09:37:32 +02:00
|
|
|
@if ($account->gateway_fee_enabled && !$account->invoice_item_taxes && $account->invoice_taxes && count($taxRates))
|
2017-03-19 15:45:44 +01:00
|
|
|
<br/>{{ trans('texts.fees_tax_help') }}
|
2017-03-17 11:13:27 +01:00
|
|
|
@endif
|
|
|
|
</div>
|
2017-03-14 14:18:31 +01:00
|
|
|
|
2017-03-16 15:03:17 +01:00
|
|
|
<br/><b>{{ trans('texts.gateway_fees_disclaimer') }}</b>
|
|
|
|
|
2017-03-14 14:18:31 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<input type="hidden" name="gateway_type_id" id="payment-limit-gateway-type">
|
2016-09-15 12:41:09 +02:00
|
|
|
</div>
|
2017-02-18 22:20:03 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
2016-09-15 12:41:09 +02:00
|
|
|
|
2017-03-26 10:45:17 +02:00
|
|
|
<div class="modal-footer">
|
2016-09-15 12:41:09 +02:00
|
|
|
<button type="button" class="btn btn-default"
|
|
|
|
data-dismiss="modal">{{ trans('texts.cancel') }}</button>
|
2017-03-19 14:31:25 +01:00
|
|
|
<button type="submit" class="btn btn-primary" id="modalSave">{{ trans('texts.save') }}</button>
|
2016-09-15 12:41:09 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
{!! Former::close() !!}
|
|
|
|
|
2015-03-16 22:45:25 +01:00
|
|
|
<script>
|
2015-11-11 13:17:58 +01:00
|
|
|
window.onDatatableReady = actionListHandler;
|
2016-09-15 12:41:09 +02:00
|
|
|
|
2017-05-08 21:10:39 +02:00
|
|
|
var taxRates = {!! $taxRates !!};
|
2017-03-14 16:45:36 +01:00
|
|
|
var taxRatesMap = {};
|
|
|
|
for (var i=0; i<taxRates.length; i++) {
|
|
|
|
var taxRate = taxRates[i];
|
|
|
|
taxRatesMap[taxRate.public_id] = taxRate;
|
|
|
|
}
|
|
|
|
var gatewaySettings = {};
|
|
|
|
|
|
|
|
@foreach ($account->account_gateway_settings as $setting)
|
|
|
|
gatewaySettings[{{ $setting->gateway_type_id }}] = {!! $setting !!};
|
|
|
|
@endforeach
|
2017-03-14 14:18:31 +01:00
|
|
|
|
2017-03-14 16:45:36 +01:00
|
|
|
//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];
|
2017-03-14 14:18:31 +01:00
|
|
|
var modalLabel = {!! json_encode(trans('texts.set_limits_fees')) !!};
|
2016-09-15 12:41:09 +02:00
|
|
|
$('#paymentLimitsModalLabel').text(modalLabel.replace(':gateway_type', gateway_type));
|
|
|
|
|
2017-03-14 21:39:52 +01:00
|
|
|
var min_limit = settings ? settings.min_limit : null;
|
|
|
|
var max_limit = settings ? settings.max_limit : null
|
2016-09-15 12:41:09 +02:00
|
|
|
|
2017-03-14 21:39:52 +01:00
|
|
|
limitsSlider.noUiSlider.set([min_limit !== null ? min_limit : 0, max_limit !== null ? max_limit : 100000]);
|
|
|
|
|
|
|
|
if (min_limit !== null) {
|
2016-09-15 12:41:09 +02:00
|
|
|
$('#payment-limit-min').removeAttr('disabled');
|
|
|
|
$('#payment-limit-min-enable').prop('checked', true);
|
|
|
|
} else {
|
|
|
|
$('#payment-limit-min').attr('disabled', 'disabled');
|
|
|
|
$('#payment-limit-min-enable').prop('checked', false);
|
|
|
|
}
|
|
|
|
|
2017-03-14 21:39:52 +01:00
|
|
|
if (max_limit !== null) {
|
2016-09-15 12:41:09 +02:00
|
|
|
$('#payment-limit-max').removeAttr('disabled');
|
|
|
|
$('#payment-limit-max-enable').prop('checked', true);
|
|
|
|
} else {
|
|
|
|
$('#payment-limit-max').attr('disabled', 'disabled');
|
|
|
|
$('#payment-limit-max-enable').prop('checked', false);
|
|
|
|
}
|
|
|
|
|
|
|
|
$('#payment-limit-gateway-type').val(gateway_type_id);
|
2017-03-14 21:39:52 +01:00
|
|
|
|
|
|
|
if (settings) {
|
|
|
|
$('#fee_amount').val(settings.fee_amount);
|
|
|
|
$('#fee_percent').val(settings.fee_percent);
|
2019-01-30 12:00:26 +01:00
|
|
|
$('#fee_cap').val(settings.fee_cap > 0 ? settings.fee_cap : '');
|
|
|
|
$('#adjust_fee_percent').prop('checked', settings.adjust_fee_percent);
|
2017-03-14 21:39:52 +01:00
|
|
|
setTaxRate(1, settings.fee_tax_name1, settings.fee_tax_rate1);
|
|
|
|
setTaxRate(2, settings.fee_tax_name2, settings.fee_tax_rate2);
|
2017-03-16 15:15:58 +01:00
|
|
|
} else {
|
|
|
|
$('#fee_amount').val('');
|
|
|
|
$('#fee_percent').val('');
|
2019-01-30 12:00:26 +01:00
|
|
|
$('#fee_cap').val('');
|
|
|
|
$('#adjust_fee_percent').prop('checked', false);
|
2017-03-16 15:15:58 +01:00
|
|
|
setTaxRate(1, '', '');
|
|
|
|
setTaxRate(2, '', '');
|
2017-03-14 21:39:52 +01:00
|
|
|
}
|
2016-09-15 12:41:09 +02:00
|
|
|
|
2017-03-14 21:39:52 +01:00
|
|
|
updateFeeSample();
|
2017-03-17 11:13:27 +01:00
|
|
|
|
2018-04-13 12:50:38 +02:00
|
|
|
if (gateway_type_id == {{ GATEWAY_TYPE_CUSTOM1 }} ||
|
|
|
|
gateway_type_id == {{ GATEWAY_TYPE_CUSTOM2 }} ||
|
2019-01-30 12:00:26 +01:00
|
|
|
gateway_type_id == {{ GATEWAY_TYPE_CUSTOM3 }} ||
|
2018-04-13 12:50:38 +02:00
|
|
|
{{ $account->gateway_fee_enabled ? '0' : '1' }}) {
|
2017-03-24 14:28:31 +01:00
|
|
|
$('#feesEnabled').hide();
|
|
|
|
$('#feesDisabled').show();
|
|
|
|
} else {
|
|
|
|
$('#feesDisabled').hide();
|
|
|
|
$('#feesEnabled').show();
|
|
|
|
}
|
|
|
|
|
|
|
|
$('#paymentLimitsModal').modal('show');
|
2016-09-15 12:41:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
var limitsSlider = document.getElementById('payment-limits-slider');
|
|
|
|
noUiSlider.create(limitsSlider, {
|
|
|
|
start: [0, 100000],
|
|
|
|
connect: true,
|
|
|
|
range: {
|
|
|
|
'min': [0, 1],
|
|
|
|
'30%': [500, 1],
|
|
|
|
'70%': [5000, 1],
|
|
|
|
'max': [100000, 1]
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
limitsSlider.noUiSlider.on('update', function (values, handle) {
|
2016-09-16 11:46:53 +02:00
|
|
|
var value = Math.round(values[handle]);
|
2016-09-15 12:41:09 +02:00
|
|
|
if (handle == 1) {
|
2016-09-16 11:46:53 +02:00
|
|
|
$('#payment-limit-max').val(value).removeAttr('disabled');
|
2016-09-15 12:41:09 +02:00
|
|
|
$('#payment-limit-max-enable').prop('checked', true);
|
|
|
|
} else {
|
2016-09-16 11:46:53 +02:00
|
|
|
$('#payment-limit-min').val(value).removeAttr('disabled');
|
2016-09-15 12:41:09 +02:00
|
|
|
$('#payment-limit-min-enable').prop('checked', true);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2016-09-16 11:46:53 +02:00
|
|
|
$('#payment-limit-min').on('change input', function () {
|
2016-09-15 12:41:09 +02:00
|
|
|
setTimeout(function () {
|
|
|
|
limitsSlider.noUiSlider.set([$('#payment-limit-min').val(), null]);
|
|
|
|
}, 100);
|
|
|
|
$('#payment-limit-min-enable').attr('checked', 'checked');
|
|
|
|
});
|
|
|
|
|
2016-09-16 11:46:53 +02:00
|
|
|
$('#payment-limit-max').on('change input', function () {
|
2016-09-15 12:41:09 +02:00
|
|
|
setTimeout(function () {
|
|
|
|
limitsSlider.noUiSlider.set([null, $('#payment-limit-max').val()]);
|
|
|
|
}, 100);
|
|
|
|
$('#payment-limit-max-enable').attr('checked', 'checked');
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#payment-limit-min-enable').change(function () {
|
|
|
|
if ($(this).is(':checked')) {
|
|
|
|
$('#payment-limit-min').removeAttr('disabled');
|
|
|
|
} else {
|
|
|
|
$('#payment-limit-min').attr('disabled', 'disabled');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#payment-limit-max-enable').change(function () {
|
|
|
|
if ($(this).is(':checked')) {
|
|
|
|
$('#payment-limit-max').removeAttr('disabled');
|
|
|
|
} else {
|
|
|
|
$('#payment-limit-max').attr('disabled', 'disabled');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2017-03-14 14:18:31 +01:00
|
|
|
function updateFeeSample() {
|
|
|
|
var feeAmount = NINJA.parseFloat($('#fee_amount').val()) || 0;
|
|
|
|
var feePercent = NINJA.parseFloat($('#fee_percent').val()) || 0;
|
2019-01-30 12:00:26 +01:00
|
|
|
var feeCap = NINJA.parseFloat($('#fee_cap').val()) || 0;
|
|
|
|
var total = feeAmount;
|
|
|
|
|
|
|
|
if (feePercent > 0) {
|
|
|
|
if ($('#adjust_fee_percent').is(':checked')) {
|
|
|
|
total += (100 + feeAmount) / (1 - feePercent / 100) - (100 + feeAmount);
|
|
|
|
} else {
|
|
|
|
total += 100 * feePercent / 100;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-14 14:18:31 +01:00
|
|
|
var subtotal = total;
|
2017-03-15 16:09:23 +01:00
|
|
|
|
2017-03-14 14:18:31 +01:00
|
|
|
var taxRate1 = $('#tax_rate1').val();
|
|
|
|
if (taxRate1) {
|
2017-03-14 16:45:36 +01:00
|
|
|
taxRate1 = NINJA.parseFloat(taxRatesMap[taxRate1].rate);
|
2017-03-14 14:18:31 +01:00
|
|
|
total += subtotal * taxRate1 / 100;
|
|
|
|
}
|
|
|
|
|
|
|
|
var taxRate2 = NINJA.parseFloat($('#tax_rate2').val());
|
|
|
|
if (taxRate2) {
|
2017-03-14 16:45:36 +01:00
|
|
|
taxRate2 = NINJA.parseFloat(taxRatesMap[taxRate2].rate);
|
2017-03-14 14:18:31 +01:00
|
|
|
total += subtotal * taxRate2 / 100;
|
|
|
|
}
|
|
|
|
|
2019-01-30 12:00:26 +01:00
|
|
|
if (feeCap > 0) {
|
|
|
|
total = Math.min(total, feeCap);
|
|
|
|
}
|
|
|
|
|
2017-03-16 21:10:13 +01:00
|
|
|
if (total >= 0) {
|
2017-03-16 16:32:46 +01:00
|
|
|
var str = "{{ trans('texts.fees_sample') }}";
|
|
|
|
} else {
|
|
|
|
var str = "{{ trans('texts.discount_sample') }}";
|
|
|
|
}
|
2019-01-30 12:00:26 +01:00
|
|
|
|
2017-03-14 14:18:31 +01:00
|
|
|
str = str.replace(':amount', formatMoney(100));
|
|
|
|
str = str.replace(':total', formatMoney(total));
|
|
|
|
$('#feeSample').text(str);
|
|
|
|
}
|
|
|
|
|
|
|
|
function onTaxRateChange(instance) {
|
|
|
|
var taxRate = $('#tax_rate' + instance).val();
|
|
|
|
if (taxRate) {
|
2017-03-14 16:45:36 +01:00
|
|
|
taxRate = taxRatesMap[taxRate];
|
2017-03-14 14:18:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$('#fee_tax_name' + instance).val(taxRate ? taxRate.name : '');
|
|
|
|
$('#fee_tax_rate' + instance).val(taxRate ? taxRate.rate : '');
|
|
|
|
|
|
|
|
updateFeeSample();
|
|
|
|
}
|
|
|
|
|
2017-03-14 16:45:36 +01:00
|
|
|
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);
|
|
|
|
}
|
2017-03-16 15:24:50 +01:00
|
|
|
|
2015-11-11 13:20:51 +01:00
|
|
|
</script>
|
2015-03-16 22:45:25 +01:00
|
|
|
|
2016-06-09 09:56:22 +02:00
|
|
|
@stop
|