Compare commits

...

3 Commits

2 changed files with 6 additions and 0 deletions
@@ -37,6 +37,7 @@ class MappableTransactionResource extends JsonResource
'owner_type' => Transaction::class,
'owner_id'=> $this->id,
'owner_reference'=> $reference,
'created_at'=> $this->created_at, // invoice date
];
}
}
@@ -27,16 +27,19 @@ class MappableTransactionWithDetailsResource extends JsonResource
'order_reference' => null,
'bill_no' => null,
'marking' => null,
'created_at' => null
];
if ($this->type === TransactionType::PAYMENT) {
$order = $this->owner->owner->owner;
$data['order_reference'] = $order->reference;
$data['debtor_code'] = $order->companyModule->company->debtor;
$data['created_at'] = $this->owner->created_at; // invoice date
} elseif (in_array($this->type, [TransactionType::GROUP_PAYMENT, TransactionType::TOP_UP])) {
$connection = $this->owner->owner->inviters()->withPivot('invitee_reference')->first();
$data['marking'] = $connection ? $connection->pivot->invitee_reference : '';
$data['bill_no'] = $this->bill_no;
$data['created_at'] = $this->created_at;
} else {
$payments = $this->transactions()
->payments()->where('status', ApprovalStatus::APPROVED)
@@ -54,6 +57,7 @@ class MappableTransactionWithDetailsResource extends JsonResource
'type' => $payment->type,
'marking' => null,
'amount' => $payment->amount,
'created_at' => $this->created_at
];
})->toArray();
} else {
@@ -61,6 +65,7 @@ class MappableTransactionWithDetailsResource extends JsonResource
$data['amount'] = 'Transaction Type not allowed';
$data['transaction_type'] = $this->type;
$data['payment_transactions'] = null;
$data['created_at'] = null;
}
}