diff --git a/app/Models/CompanyGateway.php b/app/Models/CompanyGateway.php index 239666be3da3..6495fae14aaf 100644 --- a/app/Models/CompanyGateway.php +++ b/app/Models/CompanyGateway.php @@ -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; } diff --git a/app/PaymentDrivers/BaseDriver.php b/app/PaymentDrivers/BaseDriver.php index 32b4316ea6a6..534201dbc80b 100644 --- a/app/PaymentDrivers/BaseDriver.php +++ b/app/PaymentDrivers/BaseDriver.php @@ -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) {