<?php

namespace App\Classes\Modules\Transactions\Services;

use App\Classes\General\Eloquent\AbstractUpdateRecord;
use App\Classes\General\Eloquent\AbstractUpdateRelationshipRecord;
use App\Classes\Modules\Transactions\DataTransferObjects\TransactionObject;
use App\Models\Booking;
use App\Models\Transaction;

class UpdatesTransaction extends AbstractUpdateRecord
{
    /**
     * @param Transaction $transaction
     * @param TransactionObject $object
     * @return \Illuminate\Database\Eloquent\Model
     * @throws \App\Classes\Exceptions\MalformedRequestException
     */
    public function execute(Transaction $transaction, TransactionObject $object) {
        $transaction->recipient_bank_account_id = $object->getRecipientBankAccountId();
        $transaction->payment_method = $object->getPaymentMethod();
        $transaction->amount = $object->getAmount();
        $transaction->original_amount = $object->getOriginalAmount();
        $transaction->currency_id = $object->getCurrencyId();
        $transaction->original_currency_id = $object->getOriginalCurrencyId();
        $transaction->currency_rate = $object->getCurrencyRate();
        $transaction->tax = $object->getTax();
        $transaction->service_charge = $object->getServiceCharge();

        return $this->handler($transaction);

    }
}