fix wallet transaction history and top up list bug

This commit is contained in:
Omair Saleh
2023-09-13 13:46:20 +08:00
parent 402f64364b
commit 6a6a0f0ee7
2 changed files with 14 additions and 2 deletions
+3 -2
View File
@@ -2,6 +2,7 @@
namespace App\Http\Resources;
use App\Classes\ValueObjects\Constants\ApprovalStatus;
use App\Classes\ValueObjects\Constants\TransactionType;
use Illuminate\Http\Resources\Json\JsonResource;
@@ -21,8 +22,8 @@ class WalletResource extends JsonResource
'currency_id' => $this->currency_id,
'amount' => (double) $this->amount,
'company_id' => (int) $this->owner->id,
'transactions' => $this->whenLoaded('transactions', WalletTransactionResource::collection($this->transactions()->whereIn('status', [2, 3])->orderBy('id', 'DESC')->get()), []),
'top_up_records' => $this->whenLoaded('transactions', WalletTransactionResource::collection($this->transactions()->whereNotIn('status', [0])->where('type', TransactionType::TOP_UP)->orderBy('id', 'DESC')->get()), []),
'transactions' => $this->whenLoaded('transactions', WalletTransactionResource::collection($this->transactions()->orderBy('id', 'DESC')->get()), []),
'top_up_records' => $this->whenLoaded('transactions', WalletTransactionResource::collection($this->transactions()->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])->orderBy('id', 'DESC')->get()), []),
'company_module_marking' => $this->owner->connections->first()->invitee_reference,
];
}
@@ -35,6 +35,17 @@ class WalletTransactionResource extends JsonResource
break;
}
$marking = $order->reference;
$description = 'Payment For order refs.'.'<a href="'.route('order.details', $marking).'">'.$marking.'</a>';
break;
case TransactionType::GROUP_PAYMENT:
$order = Transaction::where('payment_reference', $this->bill_no)->first()->owner->owner->owner;
if(!$order) {
$description = 'Payment for unknown order, please contact tech support.';
break;
}
$marking = $order->reference;
$description = 'Payment For order refs.'.'<a href="'.route('order.details', $marking).'">'.$marking.'</a>';
break;