<?php

namespace App\Classes\Modules\Transactions\Services;

use App\Classes\General\Eloquent\AbstractUpdateRecord;
use App\Classes\Modules\Transactions\DataTransferObjects\TransactionDetailObject;
use App\Models\TransactionDetail;

class UpdatesTransactionDetail extends AbstractUpdateRecord
{
    /**
     * @param TransactionDetail $transactionDetail
     * @param TransactionDetailObject $object
     * @return \Illuminate\Database\Eloquent\Model
     * @throws \App\Classes\Exceptions\MalformedRequestException
     */
    public function execute(TransactionDetail $transactionDetail, TransactionDetailObject $object) {
        $transactionDetail->reference = $object->getReference();
        $transactionDetail->name = $object->getName();
        $transactionDetail->quantity = $object->getQuantity();
        $transactionDetail->price = $object->getPrice();
        $transactionDetail->amount = $object->getAmount();

        return $this->handler($transactionDetail);

    }
}