Skip to content

Commit 56204b3

Browse files
committed
ran php-cs-fixer & upgraded ember dependencies
1 parent 5d18855 commit 56204b3

11 files changed

Lines changed: 473 additions & 561 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
"dependencies": {
4646
"@babel/core": "^7.23.2",
4747
"@fleetbase/ember-core": "^0.3.24",
48-
"@fleetbase/ember-ui": "^0.3.39",
48+
"@fleetbase/ember-ui": "^0.3.41",
4949
"@fleetbase/fleetops-data": "^0.1.37",
5050
"@fortawesome/ember-fontawesome": "^2.0.0",
5151
"@fortawesome/fontawesome-svg-core": "6.4.0",

pnpm-lock.yaml

Lines changed: 371 additions & 460 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pnpm-workspace.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ allowBuilds:
55
'@fortawesome/free-solid-svg-icons': false
66
core-js: false
77
fsevents: false
8-
minimumReleaseAge: 0
8+
minimumReleaseAge: 0
9+
packages: []

server/src/Console/Commands/VerifyTalerSettlements.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public function handle(PaymentGatewayManager $gatewayManager): int
6565
? 'wire_reconciled'
6666
: ($status === 'paid' ? 'settlement_checked' : 'not_settled');
6767
$transaction->reconciliation_checked_at = now();
68-
$transaction->reconciliation_data = [
68+
$transaction->reconciliation_data = [
6969
'http_status' => $result['http_status'] ?? null,
7070
'order_status' => $status,
7171
'wired' => $wired,
@@ -76,9 +76,9 @@ public function handle(PaymentGatewayManager $gatewayManager): int
7676
$transaction->save();
7777
$checked++;
7878
} catch (\Throwable $e) {
79-
$transaction->reconciliation_status = 'error';
79+
$transaction->reconciliation_status = 'error';
8080
$transaction->reconciliation_checked_at = now();
81-
$transaction->reconciliation_data = [
81+
$transaction->reconciliation_data = [
8282
'error' => $e->getMessage(),
8383
];
8484
$transaction->save();

server/src/Gateways/TalerDriver.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
use Fleetbase\Ledger\DTO\PurchaseRequest;
77
use Fleetbase\Ledger\DTO\RefundRequest;
88
use Fleetbase\Ledger\Exceptions\WebhookSignatureException;
9+
use Fleetbase\Support\Utils;
910
use Illuminate\Http\Client\Response as HttpResponse;
1011
use Illuminate\Http\Request;
1112
use Illuminate\Support\Facades\Http;
1213
use Illuminate\Support\Str;
13-
use Fleetbase\Support\Utils;
1414
use Milon\Barcode\Facades\DNS2DFacade as DNS2D;
1515

1616
/**
@@ -505,8 +505,8 @@ public function refund(RefundRequest $request): GatewayResponse
505505
'amount' => $talerAmount,
506506
]);
507507

508-
$rawResponse = $response->json() ?? [];
509-
$refundUri = $rawResponse['taler_refund_uri'] ?? null;
508+
$rawResponse = $response->json() ?? [];
509+
$refundUri = $rawResponse['taler_refund_uri'] ?? null;
510510
$refundStatus = $refundUri ? 'wallet_uri_returned' : 'backend_approved';
511511

512512
return GatewayResponse::success(

server/src/Http/Controllers/Internal/v1/GatewayController.php

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,16 @@ public function drivers(): JsonResponse
4545

4646
public function summary(): JsonResponse
4747
{
48-
$companyUuid = session('company');
49-
$gateways = Gateway::where('company_uuid', $companyUuid)->get();
48+
$companyUuid = session('company');
49+
$gateways = Gateway::where('company_uuid', $companyUuid)->get();
5050
$gatewayUuids = $gateways->pluck('uuid');
51-
$lastPayment = $this->latestGatewayTransaction($gatewayUuids, fn ($query) => $query->whereIn('event_type', [
51+
$lastPayment = $this->latestGatewayTransaction($gatewayUuids, fn ($query) => $query->whereIn('event_type', [
5252
\Fleetbase\Ledger\DTO\GatewayResponse::EVENT_PAYMENT_PENDING,
5353
\Fleetbase\Ledger\DTO\GatewayResponse::EVENT_PAYMENT_SUCCEEDED,
5454
]));
55-
$lastRefund = $this->latestGatewayTransaction($gatewayUuids, fn ($query) => $query->where('type', 'refund'));
55+
$lastRefund = $this->latestGatewayTransaction($gatewayUuids, fn ($query) => $query->where('type', 'refund'));
5656
$lastSettlement = $this->latestGatewayTransaction($gatewayUuids, fn ($query) => $query->whereNotNull('reconciliation_checked_at'), 'reconciliation_checked_at');
57-
$driverSummary = collect($this->paymentService->getDriverManifest())->map(function ($driver) use ($gateways) {
57+
$driverSummary = collect($this->paymentService->getDriverManifest())->map(function ($driver) use ($gateways) {
5858
$driverGateways = $gateways->where('driver', $driver['code']);
5959

6060
return [
@@ -69,7 +69,7 @@ public function summary(): JsonResponse
6969
})->values();
7070

7171
return response()->json([
72-
'status' => 'ok',
72+
'status' => 'ok',
7373
'summary' => [
7474
'total_gateways' => $gateways->count(),
7575
'active_gateways' => $gateways->where('status', 'active')->count(),
@@ -202,11 +202,11 @@ public function testCredentials(Request $request, string $id): JsonResponse
202202
$result = $this->sanitizeProviderResult($driver->testCredentials());
203203

204204
$this->recordGatewayDiagnostic($gateway, 'last_credential_test', [
205-
'status' => $result['status'] ?? (($result['ok'] ?? false) ? 'success' : 'failed'),
206-
'successful' => (bool) ($result['ok'] ?? false),
207-
'message' => $result['message'] ?? null,
205+
'status' => $result['status'] ?? (($result['ok'] ?? false) ? 'success' : 'failed'),
206+
'successful' => (bool) ($result['ok'] ?? false),
207+
'message' => $result['message'] ?? null,
208208
'http_status' => $result['http_status'] ?? null,
209-
'checked_at' => now()->toISOString(),
209+
'checked_at' => now()->toISOString(),
210210
]);
211211

212212
return response()->json($result, ($result['ok'] ?? false) ? 200 : 422);
@@ -329,7 +329,7 @@ public function diagnostics(Request $request, string $id): JsonResponse
329329
$lastTestOrder = $diagnosticMeta['last_test_order'] ?? [];
330330

331331
return response()->json([
332-
'status' => 'ok',
332+
'status' => 'ok',
333333
'gateway' => [
334334
'id' => $gateway->public_id,
335335
'uuid' => $gateway->uuid,
@@ -350,10 +350,10 @@ public function diagnostics(Request $request, string $id): JsonResponse
350350
'last_payment_event_at' => optional($lastPayment?->created_at)->toISOString(),
351351
'last_refund_event_at' => optional($lastRefund?->created_at)->toISOString(),
352352
'last_settlement_seen_at' => optional($lastSettlement?->reconciliation_checked_at)->toISOString(),
353-
'last_reconciliation_status' => $lastSettlement?->reconciliation_status,
354-
'last_credential_test' => $lastCredentialTest ?: null,
355-
'last_webhook_registration' => $lastWebhookRegistration ?: null,
356-
'last_test_order' => $lastTestOrder ?: null,
353+
'last_reconciliation_status' => $lastSettlement?->reconciliation_status,
354+
'last_credential_test' => $lastCredentialTest ?: null,
355+
'last_webhook_registration' => $lastWebhookRegistration ?: null,
356+
'last_test_order' => $lastTestOrder ?: null,
357357
],
358358
'last_webhook' => $lastWebhook ? (new GatewayTransactionResource($lastWebhook))->resolve() : null,
359359
'last_payment' => $lastPayment ? (new GatewayTransactionResource($lastPayment))->resolve() : null,
@@ -390,7 +390,7 @@ private function latestGatewayTransaction($gatewayUuids, callable $scope, string
390390

391391
private function recordGatewayDiagnostic(Gateway $gateway, string $key, array $summary): void
392392
{
393-
$meta = $gateway->meta ?? [];
393+
$meta = $gateway->meta ?? [];
394394
$meta['diagnostics'][$key] = array_filter($summary, fn ($value) => $value !== null);
395395

396396
$gateway->forceFill(['meta' => $meta])->save();

server/src/Http/Controllers/Internal/v1/InvoiceController.php

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
namespace Fleetbase\Ledger\Http\Controllers\Internal\v1;
44

5+
use Fleetbase\Ledger\DTO\RefundRequest;
56
use Fleetbase\Ledger\Http\Controllers\LedgerResourceController;
67
use Fleetbase\Ledger\Http\Resources\v1\Invoice as InvoiceResource;
78
use Fleetbase\Ledger\Http\Resources\v1\Transaction as TransactionResource;
8-
use Fleetbase\Ledger\DTO\RefundRequest;
99
use Fleetbase\Ledger\Models\GatewayTransaction;
1010
use Fleetbase\Ledger\Models\Invoice;
1111
use Fleetbase\Ledger\Models\InvoiceItem;
@@ -156,13 +156,13 @@ public function refundOptions(string $id, Request $request): JsonResponse
156156

157157
return response()->json([
158158
'invoice' => [
159-
'id' => $invoice->public_id,
160-
'uuid' => $invoice->uuid,
161-
'number' => $invoice->number,
162-
'currency' => $invoice->currency,
163-
'total_amount' => (int) $invoice->total_amount,
164-
'amount_paid' => (int) $invoice->amount_paid,
165-
'refunded_amount' => $this->invoiceRefundedAmount($invoice),
159+
'id' => $invoice->public_id,
160+
'uuid' => $invoice->uuid,
161+
'number' => $invoice->number,
162+
'currency' => $invoice->currency,
163+
'total_amount' => (int) $invoice->total_amount,
164+
'amount_paid' => (int) $invoice->amount_paid,
165+
'refunded_amount' => $this->invoiceRefundedAmount($invoice),
166166
'remaining_refundable_amount' => $this->invoiceRemainingRefundableAmount($invoice),
167167
],
168168
'options' => $options,
@@ -182,21 +182,21 @@ public function refund(string $id, Request $request, PaymentService $paymentServ
182182
'reason' => 'nullable|string|max:500',
183183
]);
184184

185-
$options = collect($this->refundableGatewayTransactions($invoice));
185+
$options = collect($this->refundableGatewayTransactions($invoice));
186186
$selected = $options->firstWhere('gateway_transaction_id', $request->input('gateway_transaction_id'));
187187

188188
if (!$selected) {
189189
return response()->json(['error' => 'The selected payment cannot be refunded.'], 422);
190190
}
191191

192-
$amount = $request->integer('amount');
192+
$amount = $request->integer('amount');
193193
$remainingInvoiceAmount = $this->invoiceRemainingRefundableAmount($invoice);
194194
$remainingPaymentAmount = (int) data_get($selected, 'refundable_amount', 0);
195-
$maxRefundableAmount = min($remainingInvoiceAmount, $remainingPaymentAmount);
195+
$maxRefundableAmount = min($remainingInvoiceAmount, $remainingPaymentAmount);
196196

197197
if ($amount > $maxRefundableAmount) {
198198
return response()->json([
199-
'error' => 'Refund amount exceeds the remaining refundable amount.',
199+
'error' => 'Refund amount exceeds the remaining refundable amount.',
200200
'remaining_refundable_amount' => $maxRefundableAmount,
201201
], 422);
202202
}
@@ -210,8 +210,8 @@ public function refund(string $id, Request $request, PaymentService $paymentServ
210210
reason: $request->input('reason'),
211211
invoiceUuid: $invoice->uuid,
212212
metadata: [
213-
'refund_kind' => $refundKind,
214-
'invoice_uuid' => $invoice->uuid,
213+
'refund_kind' => $refundKind,
214+
'invoice_uuid' => $invoice->uuid,
215215
'invoice_public_id' => $invoice->public_id,
216216
],
217217
));
@@ -399,32 +399,32 @@ private function refundableGatewayTransactions(Invoice $invoice): array
399399

400400
return $gatewayTransactions
401401
->map(function (GatewayTransaction $transaction) use ($invoice, $remainingInvoiceAmount) {
402-
$paidAmount = (int) ($transaction->amount ?: $invoice->amount_paid);
402+
$paidAmount = (int) ($transaction->amount ?: $invoice->amount_paid);
403403
$refundedAmount = (int) GatewayTransaction::where('company_uuid', $invoice->company_uuid)
404404
->where('gateway_uuid', $transaction->gateway_uuid)
405405
->where('gateway_reference_id', $transaction->gateway_reference_id)
406406
->where('type', 'refund')
407407
->whereNotIn('status', ['failed'])
408408
->sum('amount');
409409
$remainingPaymentAmount = max(0, $paidAmount - $refundedAmount);
410-
$refundableAmount = min($remainingInvoiceAmount, $remainingPaymentAmount);
410+
$refundableAmount = min($remainingInvoiceAmount, $remainingPaymentAmount);
411411

412412
if (!$transaction->gateway || $refundableAmount <= 0) {
413413
return null;
414414
}
415415

416416
return [
417-
'id' => $transaction->public_id,
418-
'uuid' => $transaction->uuid,
419-
'gateway_transaction_id' => $transaction->gateway_reference_id,
420-
'amount' => $paidAmount,
421-
'currency' => $transaction->currency ?? $invoice->currency,
422-
'refunded_amount' => $refundedAmount,
423-
'refundable_amount' => $refundableAmount,
424-
'status' => $transaction->status,
425-
'created_at' => optional($transaction->created_at)->toISOString(),
417+
'id' => $transaction->public_id,
418+
'uuid' => $transaction->uuid,
419+
'gateway_transaction_id' => $transaction->gateway_reference_id,
420+
'amount' => $paidAmount,
421+
'currency' => $transaction->currency ?? $invoice->currency,
422+
'refunded_amount' => $refundedAmount,
423+
'refundable_amount' => $refundableAmount,
424+
'status' => $transaction->status,
425+
'created_at' => optional($transaction->created_at)->toISOString(),
426426
'requires_customer_action' => $transaction->gateway->driver === 'taler',
427-
'gateway' => [
427+
'gateway' => [
428428
'id' => $transaction->gateway->public_id ?? $transaction->gateway->uuid,
429429
'uuid' => $transaction->gateway->uuid,
430430
'public_id' => $transaction->gateway->public_id,

server/src/Http/Resources/v1/GatewayTransaction.php

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -15,31 +15,31 @@ class GatewayTransaction extends FleetbaseResource
1515
public function toArray($request): array
1616
{
1717
return [
18-
'id' => $this->when(Http::isInternalRequest(), $this->id, $this->public_id),
19-
'uuid' => $this->when(Http::isInternalRequest(), $this->uuid),
20-
'public_id' => $this->when(Http::isInternalRequest(), $this->public_id),
21-
'company_uuid' => $this->when(Http::isInternalRequest(), $this->company_uuid),
22-
'gateway_uuid' => $this->when(Http::isInternalRequest(), $this->gateway_uuid),
23-
'gateway' => $this->whenLoaded('gateway', fn () => new Gateway($this->gateway)),
24-
'gateway_reference_id' => $this->gateway_reference_id,
25-
'gateway_transaction_id' => $this->gateway_reference_id,
26-
'event_type' => $this->event_type,
27-
'type' => $this->type,
28-
'status' => $this->status,
29-
'message' => $this->message,
30-
'amount' => $this->amount,
31-
'currency' => $this->currency,
32-
'transaction_uuid' => $this->when(Http::isInternalRequest(), $this->transaction_uuid),
33-
'processed_at' => $this->processed_at,
34-
'refund_status' => $this->refund_status,
35-
'refund_accepted_at' => $this->refund_accepted_at,
36-
'refund_expires_at' => $this->refund_expires_at,
18+
'id' => $this->when(Http::isInternalRequest(), $this->id, $this->public_id),
19+
'uuid' => $this->when(Http::isInternalRequest(), $this->uuid),
20+
'public_id' => $this->when(Http::isInternalRequest(), $this->public_id),
21+
'company_uuid' => $this->when(Http::isInternalRequest(), $this->company_uuid),
22+
'gateway_uuid' => $this->when(Http::isInternalRequest(), $this->gateway_uuid),
23+
'gateway' => $this->whenLoaded('gateway', fn () => new Gateway($this->gateway)),
24+
'gateway_reference_id' => $this->gateway_reference_id,
25+
'gateway_transaction_id' => $this->gateway_reference_id,
26+
'event_type' => $this->event_type,
27+
'type' => $this->type,
28+
'status' => $this->status,
29+
'message' => $this->message,
30+
'amount' => $this->amount,
31+
'currency' => $this->currency,
32+
'transaction_uuid' => $this->when(Http::isInternalRequest(), $this->transaction_uuid),
33+
'processed_at' => $this->processed_at,
34+
'refund_status' => $this->refund_status,
35+
'refund_accepted_at' => $this->refund_accepted_at,
36+
'refund_expires_at' => $this->refund_expires_at,
3737
'reconciliation_status' => $this->reconciliation_status,
3838
'reconciliation_checked_at' => $this->reconciliation_checked_at,
3939
'reconciliation_data' => $this->when(Http::isInternalRequest(), $this->reconciliation_data),
4040
'raw_response' => $this->when(Http::isInternalRequest(), $this->raw_response),
41-
'created_at' => $this->created_at,
42-
'updated_at' => $this->updated_at,
41+
'created_at' => $this->created_at,
42+
'updated_at' => $this->updated_at,
4343
];
4444
}
4545
}

server/src/Listeners/HandleProcessedRefund.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public function handle(RefundProcessed $event): void
7070
'amount' => $amount,
7171
'net_amount' => $amount,
7272
'currency' => $currency,
73-
'description' => "Refund for invoice " . ($invoice?->number ?? $response->gatewayTransactionId),
73+
'description' => 'Refund for invoice ' . ($invoice?->number ?? $response->gatewayTransactionId),
7474
'type' => 'gateway_refund',
7575
'direction' => 'debit',
7676
'status' => Transaction::STATUS_SUCCESS,

0 commit comments

Comments
 (0)