null safety not required

This commit is contained in:
David Bomba 2024-09-29 16:52:34 +10:00
parent 08432c70e0
commit 0a4d00158c
8 changed files with 21 additions and 23 deletions

View File

@ -39,7 +39,7 @@ class GoCardlessOAuthWebhookController extends Controller
->whereJsonContains('config->account_id', $e['links.organisation']) ->whereJsonContains('config->account_id', $e['links.organisation'])
->firstOrFail(); ->firstOrFail();
$current = $company_gateway->getConfig('__current'); $current = $company_gateway->getConfigField('__current');
if ($current) { if ($current) {
$company_gateway->setConfig($current); $company_gateway->setConfig($current);

View File

@ -425,7 +425,6 @@ class CompanyGateway extends BaseModel
$fee = 0; $fee = 0;
if ($fees_and_limits->adjust_fee_percent ?? false) { if ($fees_and_limits->adjust_fee_percent ?? false) {
$adjusted_fee = 0; $adjusted_fee = 0;
@ -452,11 +451,7 @@ class CompanyGateway extends BaseModel
} else { } else {
$fee += round(($amount * $fees_and_limits->fee_percent / 100), 2); $fee += round(($amount * $fees_and_limits->fee_percent / 100), 2);
} }
//elseif ($fees_and_limits->adjust_fee_percent) {
// $fee += round(($amount / (1 - $fees_and_limits->fee_percent / 100) - $amount), 2);
//} else {
//}
} }
} }
/* Cap fee if we have to here. */ /* Cap fee if we have to here. */
@ -470,17 +465,14 @@ class CompanyGateway extends BaseModel
if ($include_taxes) { if ($include_taxes) {
if ($fees_and_limits->fee_tax_rate1) { if ($fees_and_limits->fee_tax_rate1) {
$fee += round(($pre_tax_fee * $fees_and_limits->fee_tax_rate1 / 100), 2); $fee += round(($pre_tax_fee * $fees_and_limits->fee_tax_rate1 / 100), 2);
// info("fee after adding fee tax 1 = {$fee}");
} }
if ($fees_and_limits->fee_tax_rate2) { if ($fees_and_limits->fee_tax_rate2) {
$fee += round(($pre_tax_fee * $fees_and_limits->fee_tax_rate2 / 100), 2); $fee += round(($pre_tax_fee * $fees_and_limits->fee_tax_rate2 / 100), 2);
// info("fee after adding fee tax 2 = {$fee}");
} }
if ($fees_and_limits->fee_tax_rate3) { if ($fees_and_limits->fee_tax_rate3) {
$fee += round(($pre_tax_fee * $fees_and_limits->fee_tax_rate3 / 100), 2); $fee += round(($pre_tax_fee * $fees_and_limits->fee_tax_rate3 / 100), 2);
// info("fee after adding fee tax 3 = {$fee}");
} }
} }

View File

@ -456,7 +456,7 @@ class BaseDriver extends AbstractPaymentDriver
$invoice $invoice
->ledger() ->ledger()
->updateInvoiceBalance($adjustment, 'Adjustment for adding gateway fee'); ->updateInvoiceBalance($adjustment, 'Adjustment for adding gateway fee **Base Driver**');
$invoice->client->service()->calculateBalance(); $invoice->client->service()->calculateBalance();
} }

View File

@ -96,7 +96,7 @@ class DirectDebit implements MethodInterface, LivewireMethodInterface
'session_token' => $session_token, 'session_token' => $session_token,
'billing_request' => $response->id, 'billing_request' => $response->id,
'authorize_then_redirect' => true, 'authorize_then_redirect' => true,
'payment_hash' => $this->go_cardless->payment_hash?->hash, 'payment_hash' => $this->go_cardless->payment_hash->hash,
]), ]),
"exit_uri" => $exit_uri, "exit_uri" => $exit_uri,
"links" => [ "links" => [

View File

@ -65,7 +65,7 @@ class SEPA implements MethodInterface, LivewireMethodInterface
'method' => GatewayType::SEPA, 'method' => GatewayType::SEPA,
'session_token' => $session_token, 'session_token' => $session_token,
'authorize_then_redirect' => true, 'authorize_then_redirect' => true,
'payment_hash' => $this->go_cardless->payment_hash?->hash, 'payment_hash' => $this->go_cardless->payment_hash->hash,
]), ]),
'prefilled_customer' => [ 'prefilled_customer' => [
'given_name' => auth()->guard('contact')->user()->client->present()->first_name(), 'given_name' => auth()->guard('contact')->user()->client->present()->first_name(),

View File

@ -48,7 +48,7 @@ class PaymentMethod
$this->payment_urls = $pu->when($contains_both, function ($methods) { $this->payment_urls = $pu->when($contains_both, function ($methods) {
return $methods->reject(function ($item) { return $methods->reject(function ($item) {
return $item['gateway_type_id'] == '29'; return $item['gateway_type_id'] == '29'; //PayPal advanced credit cards, needs to be excluded here
}); });
})->toArray(); })->toArray();

View File

@ -51,7 +51,7 @@ class AddGatewayFee extends AbstractService
$invoice_items = collect($invoice_items)->filter(function ($item) { $invoice_items = collect($invoice_items)->filter(function ($item) {
return $item->type_id != '3'; return $item->type_id != '3';
}); })->toArray();
$this->invoice->line_items = $invoice_items; $this->invoice->line_items = $invoice_items;
@ -92,8 +92,6 @@ class AddGatewayFee extends AbstractService
/**Refresh Invoice values*/ /**Refresh Invoice values*/
$this->invoice = $this->invoice->calc()->getInvoice(); $this->invoice = $this->invoice->calc()->getInvoice();
nlog($this->invoice->line_items);
$new_balance = $this->invoice->balance; $new_balance = $this->invoice->balance;
if (floatval($new_balance) - floatval($balance) != 0) { if (floatval($new_balance) - floatval($balance) != 0) {

View File

@ -444,14 +444,22 @@ class InvoiceService
return $this; return $this;
} }
$pre_count = count($this->invoice->line_items); $pre_count = count((array)$this->invoice->line_items);
$items = collect($this->invoice->line_items) // $items = collect((array)$this->invoice->line_items)
->reject(function ($item) { // ->reject(function ($item) {
return $item->type_id == '3'; // return $item->type_id == '3';
// })->toArray();
$items = collect((array)$this->invoice->line_items)
->filter(function ($item) {
return $item->type_id != '3';
})->toArray(); })->toArray();
$this->invoice->line_items = array_values($items); $this->invoice->line_items = $items;
// $this->invoice->line_items = array_values($items);
$this->invoice = $this->invoice->calc()->getInvoice(); $this->invoice = $this->invoice->calc()->getInvoice();