E-Invoice - Receipt Voucher

This commit is contained in:
Dillon Ngo
2025-05-24 22:14:35 +08:00
parent de799dc356
commit b3693aa1e3
21 changed files with 543 additions and 46 deletions
@@ -8,6 +8,7 @@ use App\Classes\ValueObjects\Constants\TransactionType;
use App\Models\Booking;
use Carbon\Carbon;
use Illuminate\Http\Resources\Json\JsonResource;
use Illuminate\Support\Facades\Log;
class TransactionResource extends JsonResource
{
@@ -56,6 +57,7 @@ class TransactionResource extends JsonResource
'currency_rate' => (double) $this->currency_rate,
'status' => (int) $this->status,
'details' => TransactionDetailResource::collection($this->transactionDetails),
'receipt_voucher' => $this->type === TransactionType::PAYMENT && $this->transactions()->where('type', TransactionType::RECEIPT_VOUCHER)->latest()->first() ? new DocumentResource($this->transactions()->where('type', TransactionType::RECEIPT_VOUCHER)->latest()->first()->documents()->first()) : null,
'documents' => new DocumentResource($this->documents()->first()),
'transaction_bill' => new TransactionResource($this->when((int) $this->type === TransactionType::PAYMENT, $this->transactions()->bills()->first())),
'transaction_refunds' => TransactionResource::collection($this->when((int) $this->type === TransactionType::PAYMENT, $this->transactions()->refunds()->get())),