<?php

declare(strict_types=1);

namespace app\models;

use carono\exchange1c\interfaces\DocumentInterface;

class Purchase extends Document implements DocumentInterface
{
    public static function collectionName(): string
    {
        return 'purchase';
    }

    /**
     * @return DocumentInterface[]
     */
    public static function findDocuments1c(): ?array
    {
        return self::find()->andWhere(['status_id' => 2])->all();
    }

    /**
     * @return OfferInterface[]
     */
    public function getOffers1c(): mixed
    {
        return true;
    }

    public function getRequisites1c(): mixed
    {
        return true;
    }

    /**
     * Получаем контрагента у документа
     *
     * @return PartnerInterface
     */
    public function getPartner1c(): Account
    {
        // !!!!!!!!!!!!!!!!!!!
        return $this->user ?? new Account;
    }

    public function getExportFields1c($context = null)
    {
        return [];
    }

    /**
     * Возвращаем имя поля в базе данных, в котором хранится ID из 1с
     *
     * @return string
     */
    public static function getIdFieldName1c()
    {
        return 'onec["Ид"]';
    }

    public function setRaw1cData($cml, $object): void
    {
    }
}
