mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-09 20:52:56 +01:00
Working on gateway fees
This commit is contained in:
parent
87507c06f4
commit
0379bb61fa
@ -68,6 +68,7 @@ class ClientPortalController extends BaseController
|
||||
}
|
||||
|
||||
$account->loadLocalizationSettings($client);
|
||||
$this->invoiceRepo->clearGatewayFee($invoice);
|
||||
|
||||
if (! Input::has('phantomjs') && ! session('silent:' . $client->id) && ! Session::has($invitation->invitation_key)
|
||||
&& (! Auth::check() || Auth::user()->account_id != $invoice->account_id)) {
|
||||
|
@ -268,21 +268,8 @@ class InvoicePresenter extends EntityPresenter
|
||||
return '';
|
||||
}
|
||||
|
||||
$parts = [];
|
||||
|
||||
if (floatval($settings->fee_amount) != 0) {
|
||||
$parts[] = $account->formatMoney($settings->fee_amount, $invoice->client);
|
||||
}
|
||||
|
||||
if (floatval($settings->fee_percent) != 0) {
|
||||
$parts[] = (floor($settings->fee_percent * 1000) / 1000) . '%';
|
||||
}
|
||||
|
||||
if (! count($parts)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$str = join(' + ', $parts);
|
||||
$fee = $invoice->calcGatewayFee($gatewayTypeId);
|
||||
$fee = $account->formatMoney($fee, $invoice->client);
|
||||
|
||||
if (floatval($settings->fee_amount) < 0 || floatval($settings->fee_percent) < 0) {
|
||||
$label = trans('texts.discount');
|
||||
@ -290,6 +277,6 @@ class InvoicePresenter extends EntityPresenter
|
||||
$label = trans('texts.fee');
|
||||
}
|
||||
|
||||
return $label . ': ' . $str;
|
||||
return $fee . ' ' . $label;
|
||||
}
|
||||
}
|
||||
|
@ -1004,12 +1004,12 @@ class InvoiceRepository extends BaseRepository
|
||||
return $invoices;
|
||||
}
|
||||
|
||||
public function setGatewayFee($invoice, $gatewayTypeId)
|
||||
public function clearGatewayFee($invoice)
|
||||
{
|
||||
$account = $invoice->account;
|
||||
$location = $account->gateway_fee_location;
|
||||
|
||||
if (! $location) {
|
||||
if (! $location || $invoice->amount != $invoice->balance) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1027,10 +1027,23 @@ class InvoiceRepository extends BaseRepository
|
||||
$invoice = $this->save($data, $invoice);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function setGatewayFee($invoice, $gatewayTypeId)
|
||||
{
|
||||
$account = $invoice->account;
|
||||
$location = $account->gateway_fee_location;
|
||||
|
||||
if (! $location) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->clearGatewayFee($invoice);
|
||||
|
||||
$fee = $invoice->calcGatewayFee($gatewayTypeId);
|
||||
$data = $invoice->toArray();
|
||||
$data[$location] = $fee;
|
||||
|
||||
$this->save($data, $invoice);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user