mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 13:12:50 +01:00
Fixes for gateway fees
This commit is contained in:
parent
92e834c4e5
commit
ac3b0dfad3
@ -269,15 +269,37 @@ class CompanyGateway extends BaseModel
|
||||
*/
|
||||
public function calcGatewayFeeLabel($amount, Client $client, $gateway_type_id = GatewayType::CREDIT_CARD) :string
|
||||
{
|
||||
$label = '';
|
||||
$label = ' ';
|
||||
|
||||
$fee = $this->calcGatewayFee($amount, $gateway_type_id);
|
||||
|
||||
if ($fee > 0) {
|
||||
$fee = Number::formatMoney(round($fee, 2), $client);
|
||||
$label = ' - '.$fee.' '.ctrans('texts.fee');
|
||||
// if ($fee > 0) {
|
||||
// $fee = Number::formatMoney(round($fee, 2), $client);
|
||||
// $label = ' - '.$fee.' '.ctrans('texts.fee');
|
||||
// }
|
||||
|
||||
if($fee > 0) {
|
||||
|
||||
$fees_and_limits = $this->fees_and_limits->{$gateway_type_id};
|
||||
|
||||
if(strlen($fees_and_limits->fee_percent) >=1)
|
||||
$label .= $fees_and_limits->fee_percent . '%';
|
||||
|
||||
if(strlen($fees_and_limits->fee_amount) >=1){
|
||||
|
||||
if(strlen($label) > 1) {
|
||||
|
||||
$label .= ' + ' . Number::formatMoney($fees_and_limits->fee_amount, $client);
|
||||
|
||||
}else {
|
||||
$label .= Number::formatMoney($fees_and_limits->fee_amount, $client);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
return $label;
|
||||
}
|
||||
|
||||
|
@ -271,7 +271,7 @@ class BaseDriver extends AbstractPaymentDriver
|
||||
|
||||
$invoices->each(function ($invoice) use ($fee_total) {
|
||||
if (collect($invoice->line_items)->contains('type_id', '3')) {
|
||||
$invoice->service()->toggleFeesPaid()->save();
|
||||
$invoice->service()->toggleFeesPaid()->deletePdf()->save();
|
||||
$invoice->client->service()->updateBalance($fee_total)->save();
|
||||
$invoice->ledger()->updateInvoiceBalance($fee_total, "Gateway fee adjustment for invoice {$invoice->number}");
|
||||
}
|
||||
@ -370,6 +370,12 @@ class BaseDriver extends AbstractPaymentDriver
|
||||
|
||||
$invoices = Invoice::whereIn('id', $this->transformKeys(array_column($this->payment_hash->invoices(), 'invoice_id')))->get();
|
||||
|
||||
$invoices->each(function ($invoice){
|
||||
|
||||
$invoice->service()->deletePdf();
|
||||
|
||||
});
|
||||
|
||||
$invoices->first()->invitations->each(function ($invitation) use ($nmo){
|
||||
|
||||
if ($invitation->contact->send_email && $invitation->contact->email) {
|
||||
|
Loading…
Reference in New Issue
Block a user