<?php
/**
 * Consignment
 *
 * PHP version 8.1
 *
 * @category Class
 * @package  Vend202601
 * @author   OpenAPI Generator team
 * @link     https://openapi-generator.tech
 */

/**
 * API 2026-01
 *
 * Lightspeed Retail (X-Series) API.
 *
 * The version of the OpenAPI document: 2026-01
 * Contact: x-series.api@lightspeedhq.com
 * Generated by: https://openapi-generator.tech
 * Generator version: 7.20.0
 */

/**
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */

namespace Vend202601\Model;

use \ArrayAccess;
use \Vend202601\ObjectSerializer;

/**
 * Consignment Class Doc Comment
 *
 * @category Class
 * @package  Vend202601
 * @author   OpenAPI Generator team
 * @link     https://openapi-generator.tech
 * @implements \ArrayAccess<string, mixed>
 */
class Consignment implements ModelInterface, ArrayAccess, \JsonSerializable
{
    public const DISCRIMINATOR = null;

    /**
      * The original name of the model.
      *
      * @var string
      */
    protected static $openAPIModelName = 'Consignment';

    /**
      * Array of property to type mappings. Used for (de)serialization
      *
      * @var string[]
      */
    protected static $openAPITypes = [
        'consignment_date' => 'string',
        'created_at' => 'string',
        'deleted_at' => 'string',
        'due_at' => 'string',
        'id' => 'string',
        'name' => 'string',
        'outlet_id' => 'string',
        'received_at' => 'string',
        'reference' => 'string',
        'source_outlet_id' => 'string',
        'status' => 'string',
        'supplier_id' => 'string',
        'supplier_invoice' => 'string',
        'total_cost_gain' => 'float',
        'total_cost_loss' => 'float',
        'total_count_gain' => 'float',
        'total_count_loss' => 'float',
        'type' => 'string',
        'updated_at' => 'string',
        'version' => 'int'
    ];

    /**
      * Array of property to format mappings. Used for (de)serialization
      *
      * @var string[]
      * @phpstan-var array<string, string|null>
      * @psalm-var array<string, string|null>
      */
    protected static $openAPIFormats = [
        'consignment_date' => null,
        'created_at' => null,
        'deleted_at' => null,
        'due_at' => null,
        'id' => 'uuid',
        'name' => null,
        'outlet_id' => 'uuid',
        'received_at' => null,
        'reference' => null,
        'source_outlet_id' => 'uuid',
        'status' => null,
        'supplier_id' => 'uuid',
        'supplier_invoice' => null,
        'total_cost_gain' => 'double',
        'total_cost_loss' => 'double',
        'total_count_gain' => 'double',
        'total_count_loss' => 'double',
        'type' => null,
        'updated_at' => null,
        'version' => 'int64'
    ];

    /**
      * Array of nullable properties. Used for (de)serialization
      *
      * @var boolean[]
      */
    protected static array $openAPINullables = [
        'consignment_date' => false,
        'created_at' => false,
        'deleted_at' => true,
        'due_at' => true,
        'id' => false,
        'name' => false,
        'outlet_id' => false,
        'received_at' => true,
        'reference' => true,
        'source_outlet_id' => true,
        'status' => false,
        'supplier_id' => true,
        'supplier_invoice' => true,
        'total_cost_gain' => true,
        'total_cost_loss' => true,
        'total_count_gain' => true,
        'total_count_loss' => true,
        'type' => false,
        'updated_at' => false,
        'version' => false
    ];

    /**
      * If a nullable field gets set to null, insert it here
      *
      * @var boolean[]
      */
    protected array $openAPINullablesSetToNull = [];

    /**
     * Array of property to type mappings. Used for (de)serialization
     *
     * @return array
     */
    public static function openAPITypes()
    {
        return self::$openAPITypes;
    }

    /**
     * Array of property to format mappings. Used for (de)serialization
     *
     * @return array
     */
    public static function openAPIFormats()
    {
        return self::$openAPIFormats;
    }

    /**
     * Array of nullable properties
     *
     * @return array
     */
    protected static function openAPINullables(): array
    {
        return self::$openAPINullables;
    }

    /**
     * Array of nullable field names deliberately set to null
     *
     * @return boolean[]
     */
    private function getOpenAPINullablesSetToNull(): array
    {
        return $this->openAPINullablesSetToNull;
    }

    /**
     * Setter - Array of nullable field names deliberately set to null
     *
     * @param boolean[] $openAPINullablesSetToNull
     */
    private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void
    {
        $this->openAPINullablesSetToNull = $openAPINullablesSetToNull;
    }

    /**
     * Checks if a property is nullable
     *
     * @param string $property
     * @return bool
     */
    public static function isNullable(string $property): bool
    {
        return self::openAPINullables()[$property] ?? false;
    }

    /**
     * Checks if a nullable property is set to null.
     *
     * @param string $property
     * @return bool
     */
    public function isNullableSetToNull(string $property): bool
    {
        return in_array($property, $this->getOpenAPINullablesSetToNull(), true);
    }

    /**
     * Array of attributes where the key is the local name,
     * and the value is the original name
     *
     * @var string[]
     */
    protected static $attributeMap = [
        'consignment_date' => 'consignment_date',
        'created_at' => 'created_at',
        'deleted_at' => 'deleted_at',
        'due_at' => 'due_at',
        'id' => 'id',
        'name' => 'name',
        'outlet_id' => 'outlet_id',
        'received_at' => 'received_at',
        'reference' => 'reference',
        'source_outlet_id' => 'source_outlet_id',
        'status' => 'status',
        'supplier_id' => 'supplier_id',
        'supplier_invoice' => 'supplier_invoice',
        'total_cost_gain' => 'total_cost_gain',
        'total_cost_loss' => 'total_cost_loss',
        'total_count_gain' => 'total_count_gain',
        'total_count_loss' => 'total_count_loss',
        'type' => 'type',
        'updated_at' => 'updated_at',
        'version' => 'version'
    ];

    /**
     * Array of attributes to setter functions (for deserialization of responses)
     *
     * @var string[]
     */
    protected static $setters = [
        'consignment_date' => 'setConsignmentDate',
        'created_at' => 'setCreatedAt',
        'deleted_at' => 'setDeletedAt',
        'due_at' => 'setDueAt',
        'id' => 'setId',
        'name' => 'setName',
        'outlet_id' => 'setOutletId',
        'received_at' => 'setReceivedAt',
        'reference' => 'setReference',
        'source_outlet_id' => 'setSourceOutletId',
        'status' => 'setStatus',
        'supplier_id' => 'setSupplierId',
        'supplier_invoice' => 'setSupplierInvoice',
        'total_cost_gain' => 'setTotalCostGain',
        'total_cost_loss' => 'setTotalCostLoss',
        'total_count_gain' => 'setTotalCountGain',
        'total_count_loss' => 'setTotalCountLoss',
        'type' => 'setType',
        'updated_at' => 'setUpdatedAt',
        'version' => 'setVersion'
    ];

    /**
     * Array of attributes to getter functions (for serialization of requests)
     *
     * @var string[]
     */
    protected static $getters = [
        'consignment_date' => 'getConsignmentDate',
        'created_at' => 'getCreatedAt',
        'deleted_at' => 'getDeletedAt',
        'due_at' => 'getDueAt',
        'id' => 'getId',
        'name' => 'getName',
        'outlet_id' => 'getOutletId',
        'received_at' => 'getReceivedAt',
        'reference' => 'getReference',
        'source_outlet_id' => 'getSourceOutletId',
        'status' => 'getStatus',
        'supplier_id' => 'getSupplierId',
        'supplier_invoice' => 'getSupplierInvoice',
        'total_cost_gain' => 'getTotalCostGain',
        'total_cost_loss' => 'getTotalCostLoss',
        'total_count_gain' => 'getTotalCountGain',
        'total_count_loss' => 'getTotalCountLoss',
        'type' => 'getType',
        'updated_at' => 'getUpdatedAt',
        'version' => 'getVersion'
    ];

    /**
     * Array of attributes where the key is the local name,
     * and the value is the original name
     *
     * @return array
     */
    public static function attributeMap()
    {
        return self::$attributeMap;
    }

    /**
     * Array of attributes to setter functions (for deserialization of responses)
     *
     * @return array
     */
    public static function setters()
    {
        return self::$setters;
    }

    /**
     * Array of attributes to getter functions (for serialization of requests)
     *
     * @return array
     */
    public static function getters()
    {
        return self::$getters;
    }

    /**
     * The original name of the model.
     *
     * @return string
     */
    public function getModelName()
    {
        return self::$openAPIModelName;
    }

    public const STATUS_OPEN = 'OPEN';
    public const STATUS_SENT = 'SENT';
    public const STATUS_DISPATCHED = 'DISPATCHED';
    public const STATUS_RECEIVED = 'RECEIVED';
    public const STATUS_STOCKTAKE_IN_PROGRESS = 'STOCKTAKE_IN_PROGRESS';
    public const STATUS_STOCKTAKE_SCHEDULED = 'STOCKTAKE_SCHEDULED';
    public const STATUS_STOCKTAKE_IN_PROGRESS_PROCESSED = 'STOCKTAKE_IN_PROGRESS_PROCESSED';
    public const STATUS_STOCKTAKE_COMPLETE = 'STOCKTAKE_COMPLETE';
    public const STATUS_CLOSED = 'CLOSED';
    public const STATUS_CANCELLED = 'CANCELLED';
    public const TYPE_SUPPLIER = 'SUPPLIER';
    public const TYPE_OUTLET = 'OUTLET';
    public const TYPE_STOCKTAKE = 'STOCKTAKE';
    public const TYPE__RETURN = 'RETURN';

    /**
     * Gets allowable values of the enum
     *
     * @return string[]
     */
    public function getStatusAllowableValues()
    {
        return [
            self::STATUS_OPEN,
            self::STATUS_SENT,
            self::STATUS_DISPATCHED,
            self::STATUS_RECEIVED,
            self::STATUS_STOCKTAKE_IN_PROGRESS,
            self::STATUS_STOCKTAKE_SCHEDULED,
            self::STATUS_STOCKTAKE_IN_PROGRESS_PROCESSED,
            self::STATUS_STOCKTAKE_COMPLETE,
            self::STATUS_CLOSED,
            self::STATUS_CANCELLED,
        ];
    }

    /**
     * Gets allowable values of the enum
     *
     * @return string[]
     */
    public function getTypeAllowableValues()
    {
        return [
            self::TYPE_SUPPLIER,
            self::TYPE_OUTLET,
            self::TYPE_STOCKTAKE,
            self::TYPE__RETURN,
        ];
    }

    /**
     * Associative array for storing property values
     *
     * @var mixed[]
     */
    protected $container = [];

    /**
     * Constructor
     *
     * @param mixed[]|null $data Associated array of property values
     *                      initializing the model
     */
    public function __construct(?array $data = null)
    {
        $this->setIfExists('consignment_date', $data ?? [], null);
        $this->setIfExists('created_at', $data ?? [], null);
        $this->setIfExists('deleted_at', $data ?? [], null);
        $this->setIfExists('due_at', $data ?? [], null);
        $this->setIfExists('id', $data ?? [], null);
        $this->setIfExists('name', $data ?? [], null);
        $this->setIfExists('outlet_id', $data ?? [], null);
        $this->setIfExists('received_at', $data ?? [], null);
        $this->setIfExists('reference', $data ?? [], null);
        $this->setIfExists('source_outlet_id', $data ?? [], null);
        $this->setIfExists('status', $data ?? [], null);
        $this->setIfExists('supplier_id', $data ?? [], null);
        $this->setIfExists('supplier_invoice', $data ?? [], null);
        $this->setIfExists('total_cost_gain', $data ?? [], null);
        $this->setIfExists('total_cost_loss', $data ?? [], null);
        $this->setIfExists('total_count_gain', $data ?? [], null);
        $this->setIfExists('total_count_loss', $data ?? [], null);
        $this->setIfExists('type', $data ?? [], null);
        $this->setIfExists('updated_at', $data ?? [], null);
        $this->setIfExists('version', $data ?? [], null);
    }

    /**
    * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
    * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
    * $this->openAPINullablesSetToNull array
    *
    * @param string $variableName
    * @param array  $fields
    * @param mixed  $defaultValue
    */
    private function setIfExists(string $variableName, array $fields, $defaultValue): void
    {
        if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) {
            $this->openAPINullablesSetToNull[] = $variableName;
        }

        $this->container[$variableName] = $fields[$variableName] ?? $defaultValue;
    }

    /**
     * Show all the invalid properties with reasons.
     *
     * @return array invalid properties with reasons
     */
    public function listInvalidProperties()
    {
        $invalidProperties = [];

        if ($this->container['name'] === null) {
            $invalidProperties[] = "'name' can't be null";
        }
        if ($this->container['outlet_id'] === null) {
            $invalidProperties[] = "'outlet_id' can't be null";
        }
        $allowedValues = $this->getStatusAllowableValues();
        if (!is_null($this->container['status']) && !in_array($this->container['status'], $allowedValues, true)) {
            $invalidProperties[] = sprintf(
                "invalid value '%s' for 'status', must be one of '%s'",
                $this->container['status'],
                implode("', '", $allowedValues)
            );
        }

        if ($this->container['type'] === null) {
            $invalidProperties[] = "'type' can't be null";
        }
        $allowedValues = $this->getTypeAllowableValues();
        if (!is_null($this->container['type']) && !in_array($this->container['type'], $allowedValues, true)) {
            $invalidProperties[] = sprintf(
                "invalid value '%s' for 'type', must be one of '%s'",
                $this->container['type'],
                implode("', '", $allowedValues)
            );
        }

        return $invalidProperties;
    }

    /**
     * Validate all the properties in the model
     * return true if all passed
     *
     * @return bool True if all properties are valid
     */
    public function valid()
    {
        return count($this->listInvalidProperties()) === 0;
    }


    /**
     * Gets consignment_date
     *
     * @return string|null
     */
    public function getConsignmentDate()
    {
        return $this->container['consignment_date'];
    }

    /**
     * Sets consignment_date
     *
     * @param string|null $consignment_date 11-28T19:02:15+00:00 (timestamp) - Consignment creation date.
     *
     * @return self
     */
    public function setConsignmentDate($consignment_date)
    {
        if (is_null($consignment_date)) {
            throw new \InvalidArgumentException('non-nullable consignment_date cannot be null');
        }
        $this->container['consignment_date'] = $consignment_date;

        return $this;
    }

    /**
     * Gets created_at
     *
     * @return string|null
     */
    public function getCreatedAt()
    {
        return $this->container['created_at'];
    }

    /**
     * Sets created_at
     *
     * @param string|null $created_at Creation timestamp in UTC.
     *
     * @return self
     */
    public function setCreatedAt($created_at)
    {
        if (is_null($created_at)) {
            throw new \InvalidArgumentException('non-nullable created_at cannot be null');
        }
        $this->container['created_at'] = $created_at;

        return $this;
    }

    /**
     * Gets deleted_at
     *
     * @return string|null
     */
    public function getDeletedAt()
    {
        return $this->container['deleted_at'];
    }

    /**
     * Sets deleted_at
     *
     * @param string|null $deleted_at Deletion timestamp in UTC.
     *
     * @return self
     */
    public function setDeletedAt($deleted_at)
    {
        if (is_null($deleted_at)) {
            array_push($this->openAPINullablesSetToNull, 'deleted_at');
        } else {
            $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
            $index = array_search('deleted_at', $nullablesSetToNull);
            if ($index !== FALSE) {
                unset($nullablesSetToNull[$index]);
                $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
            }
        }
        $this->container['deleted_at'] = $deleted_at;

        return $this;
    }

    /**
     * Gets due_at
     *
     * @return string|null
     */
    public function getDueAt()
    {
        return $this->container['due_at'];
    }

    /**
     * Sets due_at
     *
     * @param string|null $due_at 11-30T19:08:541+00:00 (timestamp) - Due date.
     *
     * @return self
     */
    public function setDueAt($due_at)
    {
        if (is_null($due_at)) {
            array_push($this->openAPINullablesSetToNull, 'due_at');
        } else {
            $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
            $index = array_search('due_at', $nullablesSetToNull);
            if ($index !== FALSE) {
                unset($nullablesSetToNull[$index]);
                $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
            }
        }
        $this->container['due_at'] = $due_at;

        return $this;
    }

    /**
     * Gets id
     *
     * @return string|null
     */
    public function getId()
    {
        return $this->container['id'];
    }

    /**
     * Sets id
     *
     * @param string|null $id Auto-generated object ID.
     *
     * @return self
     */
    public function setId($id)
    {
        if (is_null($id)) {
            throw new \InvalidArgumentException('non-nullable id cannot be null');
        }
        $this->container['id'] = $id;

        return $this;
    }

    /**
     * Gets name
     *
     * @return string
     */
    public function getName()
    {
        return $this->container['name'];
    }

    /**
     * Sets name
     *
     * @param string $name Tue 29 Nov 2016 (string) - Consignment name. For orders, the note field in the UI will be the name value.
     *
     * @return self
     */
    public function setName($name)
    {
        if (is_null($name)) {
            throw new \InvalidArgumentException('non-nullable name cannot be null');
        }
        $this->container['name'] = $name;

        return $this;
    }

    /**
     * Gets outlet_id
     *
     * @return string
     */
    public function getOutletId()
    {
        return $this->container['outlet_id'];
    }

    /**
     * Sets outlet_id
     *
     * @param string $outlet_id A valid ID of an outlet where stock will be received.
     *
     * @return self
     */
    public function setOutletId($outlet_id)
    {
        if (is_null($outlet_id)) {
            throw new \InvalidArgumentException('non-nullable outlet_id cannot be null');
        }
        $this->container['outlet_id'] = $outlet_id;

        return $this;
    }

    /**
     * Gets received_at
     *
     * @return string|null
     */
    public function getReceivedAt()
    {
        return $this->container['received_at'];
    }

    /**
     * Sets received_at
     *
     * @param string|null $received_at 11-30T19:08:541+00:00 (timestamp) - The date when consignment was received.
     *
     * @return self
     */
    public function setReceivedAt($received_at)
    {
        if (is_null($received_at)) {
            array_push($this->openAPINullablesSetToNull, 'received_at');
        } else {
            $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
            $index = array_search('received_at', $nullablesSetToNull);
            if ($index !== FALSE) {
                unset($nullablesSetToNull[$index]);
                $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
            }
        }
        $this->container['received_at'] = $received_at;

        return $this;
    }

    /**
     * Gets reference
     *
     * @return string|null
     */
    public function getReference()
    {
        return $this->container['reference'];
    }

    /**
     * Sets reference
     *
     * @param string|null $reference Order number.+ `total_count_gain` (number)
     *
     * @return self
     */
    public function setReference($reference)
    {
        if (is_null($reference)) {
            array_push($this->openAPINullablesSetToNull, 'reference');
        } else {
            $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
            $index = array_search('reference', $nullablesSetToNull);
            if ($index !== FALSE) {
                unset($nullablesSetToNull[$index]);
                $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
            }
        }
        $this->container['reference'] = $reference;

        return $this;
    }

    /**
     * Gets source_outlet_id
     *
     * @return string|null
     */
    public function getSourceOutletId()
    {
        return $this->container['source_outlet_id'];
    }

    /**
     * Sets source_outlet_id
     *
     * @param string|null $source_outlet_id A valid ID of an outlet where stock will come from. **Stock transfers only**.
     *
     * @return self
     */
    public function setSourceOutletId($source_outlet_id)
    {
        if (is_null($source_outlet_id)) {
            array_push($this->openAPINullablesSetToNull, 'source_outlet_id');
        } else {
            $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
            $index = array_search('source_outlet_id', $nullablesSetToNull);
            if ($index !== FALSE) {
                unset($nullablesSetToNull[$index]);
                $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
            }
        }
        $this->container['source_outlet_id'] = $source_outlet_id;

        return $this;
    }

    /**
     * Gets status
     *
     * @return string|null
     */
    public function getStatus()
    {
        return $this->container['status'];
    }

    /**
     * Sets status
     *
     * @param string|null $status * Supplier Order: One of `OPEN`, `SENT`, `DISPATCHED`, `RECEIVED`, `CANCELLED` * Outlet Transfer: One of `OPEN`, `SENT`, `RECEIVED`, `CANCELLED` * Return Order: One of `OPEN`, `SENT`, `CANCELLED` * Stocktake: One of `STOCKTAKE_SCHEDULED`, `STOCKTAKE_IN_PROGRESS`, `STOCKTAKE_IN_PROGRESS_PROCESSED`, `STOCKTAKE_COMPLETE`, `CLOSED`, `CANCELLED` This is not a definitive list and may be extended in future
     *
     * @return self
     */
    public function setStatus($status)
    {
        if (is_null($status)) {
            throw new \InvalidArgumentException('non-nullable status cannot be null');
        }
        $allowedValues = $this->getStatusAllowableValues();
        if (!in_array($status, $allowedValues, true)) {
            throw new \InvalidArgumentException(
                sprintf(
                    "Invalid value '%s' for 'status', must be one of '%s'",
                    $status,
                    implode("', '", $allowedValues)
                )
            );
        }
        $this->container['status'] = $status;

        return $this;
    }

    /**
     * Gets supplier_id
     *
     * @return string|null
     */
    public function getSupplierId()
    {
        return $this->container['supplier_id'];
    }

    /**
     * Sets supplier_id
     *
     * @param string|null $supplier_id a valid supplier ID.
     *
     * @return self
     */
    public function setSupplierId($supplier_id)
    {
        if (is_null($supplier_id)) {
            array_push($this->openAPINullablesSetToNull, 'supplier_id');
        } else {
            $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
            $index = array_search('supplier_id', $nullablesSetToNull);
            if ($index !== FALSE) {
                unset($nullablesSetToNull[$index]);
                $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
            }
        }
        $this->container['supplier_id'] = $supplier_id;

        return $this;
    }

    /**
     * Gets supplier_invoice
     *
     * @return string|null
     */
    public function getSupplierInvoice()
    {
        return $this->container['supplier_invoice'];
    }

    /**
     * Sets supplier_invoice
     *
     * @param string|null $supplier_invoice Supplier invoice number.
     *
     * @return self
     */
    public function setSupplierInvoice($supplier_invoice)
    {
        if (is_null($supplier_invoice)) {
            array_push($this->openAPINullablesSetToNull, 'supplier_invoice');
        } else {
            $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
            $index = array_search('supplier_invoice', $nullablesSetToNull);
            if ($index !== FALSE) {
                unset($nullablesSetToNull[$index]);
                $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
            }
        }
        $this->container['supplier_invoice'] = $supplier_invoice;

        return $this;
    }

    /**
     * Gets total_cost_gain
     *
     * @return float|null
     */
    public function getTotalCostGain()
    {
        return $this->container['total_cost_gain'];
    }

    /**
     * Sets total_cost_gain
     *
     * @param float|null $total_cost_gain The cost of items over the expected level.
     *
     * @return self
     */
    public function setTotalCostGain($total_cost_gain)
    {
        if (is_null($total_cost_gain)) {
            array_push($this->openAPINullablesSetToNull, 'total_cost_gain');
        } else {
            $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
            $index = array_search('total_cost_gain', $nullablesSetToNull);
            if ($index !== FALSE) {
                unset($nullablesSetToNull[$index]);
                $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
            }
        }
        $this->container['total_cost_gain'] = $total_cost_gain;

        return $this;
    }

    /**
     * Gets total_cost_loss
     *
     * @return float|null
     */
    public function getTotalCostLoss()
    {
        return $this->container['total_cost_loss'];
    }

    /**
     * Sets total_cost_loss
     *
     * @param float|null $total_cost_loss The cost of items below the expected level.
     *
     * @return self
     */
    public function setTotalCostLoss($total_cost_loss)
    {
        if (is_null($total_cost_loss)) {
            array_push($this->openAPINullablesSetToNull, 'total_cost_loss');
        } else {
            $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
            $index = array_search('total_cost_loss', $nullablesSetToNull);
            if ($index !== FALSE) {
                unset($nullablesSetToNull[$index]);
                $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
            }
        }
        $this->container['total_cost_loss'] = $total_cost_loss;

        return $this;
    }

    /**
     * Gets total_count_gain
     *
     * @return float|null
     */
    public function getTotalCountGain()
    {
        return $this->container['total_count_gain'];
    }

    /**
     * Sets total_count_gain
     *
     * @param float|null $total_count_gain The number of items over the expected level.
     *
     * @return self
     */
    public function setTotalCountGain($total_count_gain)
    {
        if (is_null($total_count_gain)) {
            array_push($this->openAPINullablesSetToNull, 'total_count_gain');
        } else {
            $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
            $index = array_search('total_count_gain', $nullablesSetToNull);
            if ($index !== FALSE) {
                unset($nullablesSetToNull[$index]);
                $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
            }
        }
        $this->container['total_count_gain'] = $total_count_gain;

        return $this;
    }

    /**
     * Gets total_count_loss
     *
     * @return float|null
     */
    public function getTotalCountLoss()
    {
        return $this->container['total_count_loss'];
    }

    /**
     * Sets total_count_loss
     *
     * @param float|null $total_count_loss The number of items below the expected level.
     *
     * @return self
     */
    public function setTotalCountLoss($total_count_loss)
    {
        if (is_null($total_count_loss)) {
            array_push($this->openAPINullablesSetToNull, 'total_count_loss');
        } else {
            $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
            $index = array_search('total_count_loss', $nullablesSetToNull);
            if ($index !== FALSE) {
                unset($nullablesSetToNull[$index]);
                $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
            }
        }
        $this->container['total_count_loss'] = $total_count_loss;

        return $this;
    }

    /**
     * Gets type
     *
     * @return string
     */
    public function getType()
    {
        return $this->container['type'];
    }

    /**
     * Sets type
     *
     * @param string $type One of `SUPPLIER`, `OUTLET`, `STOCKTAKE`, `RETURN`.
     *
     * @return self
     */
    public function setType($type)
    {
        if (is_null($type)) {
            throw new \InvalidArgumentException('non-nullable type cannot be null');
        }
        $allowedValues = $this->getTypeAllowableValues();
        if (!in_array($type, $allowedValues, true)) {
            throw new \InvalidArgumentException(
                sprintf(
                    "Invalid value '%s' for 'type', must be one of '%s'",
                    $type,
                    implode("', '", $allowedValues)
                )
            );
        }
        $this->container['type'] = $type;

        return $this;
    }

    /**
     * Gets updated_at
     *
     * @return string|null
     */
    public function getUpdatedAt()
    {
        return $this->container['updated_at'];
    }

    /**
     * Sets updated_at
     *
     * @param string|null $updated_at Last update timestamp in UTC.
     *
     * @return self
     */
    public function setUpdatedAt($updated_at)
    {
        if (is_null($updated_at)) {
            throw new \InvalidArgumentException('non-nullable updated_at cannot be null');
        }
        $this->container['updated_at'] = $updated_at;

        return $this;
    }

    /**
     * Gets version
     *
     * @return int|null
     */
    public function getVersion()
    {
        return $this->container['version'];
    }

    /**
     * Sets version
     *
     * @param int|null $version Auto-incrementing object version number.
     *
     * @return self
     */
    public function setVersion($version)
    {
        if (is_null($version)) {
            throw new \InvalidArgumentException('non-nullable version cannot be null');
        }
        $this->container['version'] = $version;

        return $this;
    }
    /**
     * Returns true if offset exists. False otherwise.
     *
     * @param integer|string $offset Offset
     *
     * @return boolean
     */
    public function offsetExists(mixed $offset): bool
    {
        return isset($this->container[$offset]);
    }

    /**
     * Gets offset.
     *
     * @param integer|string $offset Offset
     *
     * @return mixed|null
     */
    #[\ReturnTypeWillChange]
    public function offsetGet(mixed $offset)
    {
        return $this->container[$offset] ?? null;
    }

    /**
     * Sets value based on offset.
     *
     * @param int|null $offset Offset
     * @param mixed    $value  Value to be set
     *
     * @return void
     */
    public function offsetSet($offset, $value): void
    {
        if (is_null($offset)) {
            $this->container[] = $value;
        } else {
            $this->container[$offset] = $value;
        }
    }

    /**
     * Unsets offset.
     *
     * @param integer|string $offset Offset
     *
     * @return void
     */
    public function offsetUnset(mixed $offset): void
    {
        unset($this->container[$offset]);
    }

    /**
     * Serializes the object to a value that can be serialized natively by json_encode().
     * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php
     *
     * @return mixed Returns data which can be serialized by json_encode(), which is a value
     * of any type other than a resource.
     */
    #[\ReturnTypeWillChange]
    public function jsonSerialize()
    {
       return ObjectSerializer::sanitizeForSerialization($this);
    }

    /**
     * Gets the string presentation of the object
     *
     * @return string
     */
    public function __toString()
    {
        return json_encode(
            ObjectSerializer::sanitizeForSerialization($this),
            JSON_PRETTY_PRINT
        );
    }

    /**
     * Gets a header-safe presentation of the object
     *
     * @return string
     */
    public function toHeaderValue()
    {
        return json_encode(ObjectSerializer::sanitizeForSerialization($this));
    }
}


