<?php

namespace App\Classes\Modules\Accounting\Services;

use App\Classes\General\Eloquent\AbstractUpdateRecord;
use App\Classes\Modules\Accounting\DataTransferObjects\BankStatementTransactionObject;
use App\Models\StatementTransactionOwner;

class CreatesBankStatementTransactionOwner extends AbstractUpdateRecord
{

    /**
     * @param StatementTransactionOwner $model
     * @param BankStatementDetailsObject $object
     * @return \Illuminate\Database\Eloquent\Model
     * @throws \App\Classes\Exceptions\MalformedRequestException
     */
    public function execute(BankStatementTransactionObject $object)
    {
        $model = new StatementTransactionOwner();

        $model->statement_transaction_id = $object->getStatementTransactionId();
        $model->type = $object->getType();
        $model->system = $object->getSystem();
        $model->owner_type = $object->getOwnerType();
        $model->owner_id = $object->getOwnerId();
        $model->invoice_reference = $object->getInvoiceReference();
        $model->receipt_reference = $object->getReceipteReference();
        $model->is_auto_mapped = $object->getIsAutoMapped();
        $model->status = $object->getStatus();

        return $this->handler($model);
    }
}
