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

/**
 * Fortnox API
 *
 * # Documentation   The Fortnox API is organized around REST. This means that we’ve designed it to have resource-oriented URLs and be as predictable as possible for you as developer.  It also means that we use HTTP status codes when something goes wrong and HTTP verbs understod by many API clients around the web.  We use a modified version of OAuth2 for authentication to offer a secure way for both you and our users to interact.  The API is generally built to support both XML and JSON but in this documentation all the examples will be in JSON.  We encourage you to read all the articles in the [Guides & Good to Know section](https://www.fortnox.se/developer/guides-and-good-to-know/)</a> first, before going forward and learning about the different resources.  This to ensure you get an understanding of some of the shared components of the API such as parameters and error handling.  ## Rate limits  The limit per access-token is 25 requests per 5 seconds. This equals to 300 requests per minute.  [Read more about this here.](https://www.fortnox.se/developer/guides-and-good-to-know/rate-limits-for-fortnox-api/)  ## Query parameters  Use query parameters with the ?-character and separate parameters with the &-character.   **Example:**  GET - https://api.fortnox.se/3/invoices?accountnumberfrom=3000&accountnumberto=4000 Read more about our parameters [here](https://www.fortnox.se/developer/guides-and-good-to-know/parameters/)   Search the documentation using the search field in the top left corner.
 *
 * The version of the OpenAPI document: 
 * Generated by: https://openapi-generator.tech
 * Generator version: 7.19.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 Fortnox\Model;

use \ArrayAccess;
use \Fortnox\ObjectSerializer;

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

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

    /**
      * Array of property to type mappings. Used for (de)serialization
      *
      * @var string[]
      */
    protected static $openAPITypes = [
        'at_url' => 'string',
        'accounting_method' => 'string',
        'administration_fee' => 'string',
        'balance' => 'string',
        'booked' => 'bool',
        'cancelled' => 'bool',
        'comments' => 'string',
        'cost_center' => 'string',
        'credit' => 'bool',
        'credit_reference' => 'int',
        'currency' => 'string',
        'currency_rate' => 'string',
        'currency_unit' => 'float',
        'disable_payment_file' => 'bool',
        'due_date' => '\DateTime',
        'external_invoice_number' => 'string',
        'external_invoice_series' => 'string',
        'final_pay_date' => '\DateTime',
        'freight' => 'string',
        'given_number' => 'string',
        'invoice_date' => '\DateTime',
        'invoice_number' => 'string',
        'ocr' => 'string',
        'our_reference' => 'string',
        'payment_pending' => 'bool',
        'project' => 'string',
        'round_off_value' => 'string',
        'sales_type' => 'string',
        'supplier_invoice_rows' => '\Fortnox\Model\FortnoxLfSupplierInvoiceRowSingleItem[]',
        'supplier_name' => 'string',
        'supplier_number' => 'string',
        'total' => 'string',
        'vat' => 'string',
        'vat_type' => 'string',
        'voucher_number' => 'int',
        'voucher_series' => 'string',
        'voucher_year' => 'int',
        'vouchers' => '\Fortnox\Model\FortnoxLfVoucherReferenceSingleItem[]',
        'your_reference' => 'string'
    ];

    /**
      * 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 = [
        'at_url' => null,
        'accounting_method' => null,
        'administration_fee' => null,
        'balance' => null,
        'booked' => null,
        'cancelled' => null,
        'comments' => null,
        'cost_center' => null,
        'credit' => null,
        'credit_reference' => 'int32',
        'currency' => null,
        'currency_rate' => null,
        'currency_unit' => 'double',
        'disable_payment_file' => null,
        'due_date' => 'date',
        'external_invoice_number' => null,
        'external_invoice_series' => null,
        'final_pay_date' => 'date',
        'freight' => null,
        'given_number' => null,
        'invoice_date' => 'date',
        'invoice_number' => null,
        'ocr' => null,
        'our_reference' => null,
        'payment_pending' => null,
        'project' => null,
        'round_off_value' => null,
        'sales_type' => null,
        'supplier_invoice_rows' => null,
        'supplier_name' => null,
        'supplier_number' => null,
        'total' => null,
        'vat' => null,
        'vat_type' => null,
        'voucher_number' => 'int32',
        'voucher_series' => null,
        'voucher_year' => 'int32',
        'vouchers' => null,
        'your_reference' => null
    ];

    /**
      * Array of nullable properties. Used for (de)serialization
      *
      * @var boolean[]
      */
    protected static array $openAPINullables = [
        'at_url' => false,
        'accounting_method' => false,
        'administration_fee' => false,
        'balance' => false,
        'booked' => false,
        'cancelled' => false,
        'comments' => false,
        'cost_center' => false,
        'credit' => false,
        'credit_reference' => false,
        'currency' => false,
        'currency_rate' => false,
        'currency_unit' => false,
        'disable_payment_file' => false,
        'due_date' => false,
        'external_invoice_number' => false,
        'external_invoice_series' => false,
        'final_pay_date' => false,
        'freight' => false,
        'given_number' => false,
        'invoice_date' => false,
        'invoice_number' => false,
        'ocr' => false,
        'our_reference' => false,
        'payment_pending' => false,
        'project' => false,
        'round_off_value' => false,
        'sales_type' => false,
        'supplier_invoice_rows' => false,
        'supplier_name' => false,
        'supplier_number' => false,
        'total' => false,
        'vat' => false,
        'vat_type' => false,
        'voucher_number' => false,
        'voucher_series' => false,
        'voucher_year' => false,
        'vouchers' => false,
        'your_reference' => 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 = [
        'at_url' => '@url',
        'accounting_method' => 'AccountingMethod',
        'administration_fee' => 'AdministrationFee',
        'balance' => 'Balance',
        'booked' => 'Booked',
        'cancelled' => 'Cancelled',
        'comments' => 'Comments',
        'cost_center' => 'CostCenter',
        'credit' => 'Credit',
        'credit_reference' => 'CreditReference',
        'currency' => 'Currency',
        'currency_rate' => 'CurrencyRate',
        'currency_unit' => 'CurrencyUnit',
        'disable_payment_file' => 'DisablePaymentFile',
        'due_date' => 'DueDate',
        'external_invoice_number' => 'ExternalInvoiceNumber',
        'external_invoice_series' => 'ExternalInvoiceSeries',
        'final_pay_date' => 'FinalPayDate',
        'freight' => 'Freight',
        'given_number' => 'GivenNumber',
        'invoice_date' => 'InvoiceDate',
        'invoice_number' => 'InvoiceNumber',
        'ocr' => 'OCR',
        'our_reference' => 'OurReference',
        'payment_pending' => 'PaymentPending',
        'project' => 'Project',
        'round_off_value' => 'RoundOffValue',
        'sales_type' => 'SalesType',
        'supplier_invoice_rows' => 'SupplierInvoiceRows',
        'supplier_name' => 'SupplierName',
        'supplier_number' => 'SupplierNumber',
        'total' => 'Total',
        'vat' => 'VAT',
        'vat_type' => 'VATType',
        'voucher_number' => 'VoucherNumber',
        'voucher_series' => 'VoucherSeries',
        'voucher_year' => 'VoucherYear',
        'vouchers' => 'Vouchers',
        'your_reference' => 'YourReference'
    ];

    /**
     * Array of attributes to setter functions (for deserialization of responses)
     *
     * @var string[]
     */
    protected static $setters = [
        'at_url' => 'setAtUrl',
        'accounting_method' => 'setAccountingMethod',
        'administration_fee' => 'setAdministrationFee',
        'balance' => 'setBalance',
        'booked' => 'setBooked',
        'cancelled' => 'setCancelled',
        'comments' => 'setComments',
        'cost_center' => 'setCostCenter',
        'credit' => 'setCredit',
        'credit_reference' => 'setCreditReference',
        'currency' => 'setCurrency',
        'currency_rate' => 'setCurrencyRate',
        'currency_unit' => 'setCurrencyUnit',
        'disable_payment_file' => 'setDisablePaymentFile',
        'due_date' => 'setDueDate',
        'external_invoice_number' => 'setExternalInvoiceNumber',
        'external_invoice_series' => 'setExternalInvoiceSeries',
        'final_pay_date' => 'setFinalPayDate',
        'freight' => 'setFreight',
        'given_number' => 'setGivenNumber',
        'invoice_date' => 'setInvoiceDate',
        'invoice_number' => 'setInvoiceNumber',
        'ocr' => 'setOcr',
        'our_reference' => 'setOurReference',
        'payment_pending' => 'setPaymentPending',
        'project' => 'setProject',
        'round_off_value' => 'setRoundOffValue',
        'sales_type' => 'setSalesType',
        'supplier_invoice_rows' => 'setSupplierInvoiceRows',
        'supplier_name' => 'setSupplierName',
        'supplier_number' => 'setSupplierNumber',
        'total' => 'setTotal',
        'vat' => 'setVat',
        'vat_type' => 'setVatType',
        'voucher_number' => 'setVoucherNumber',
        'voucher_series' => 'setVoucherSeries',
        'voucher_year' => 'setVoucherYear',
        'vouchers' => 'setVouchers',
        'your_reference' => 'setYourReference'
    ];

    /**
     * Array of attributes to getter functions (for serialization of requests)
     *
     * @var string[]
     */
    protected static $getters = [
        'at_url' => 'getAtUrl',
        'accounting_method' => 'getAccountingMethod',
        'administration_fee' => 'getAdministrationFee',
        'balance' => 'getBalance',
        'booked' => 'getBooked',
        'cancelled' => 'getCancelled',
        'comments' => 'getComments',
        'cost_center' => 'getCostCenter',
        'credit' => 'getCredit',
        'credit_reference' => 'getCreditReference',
        'currency' => 'getCurrency',
        'currency_rate' => 'getCurrencyRate',
        'currency_unit' => 'getCurrencyUnit',
        'disable_payment_file' => 'getDisablePaymentFile',
        'due_date' => 'getDueDate',
        'external_invoice_number' => 'getExternalInvoiceNumber',
        'external_invoice_series' => 'getExternalInvoiceSeries',
        'final_pay_date' => 'getFinalPayDate',
        'freight' => 'getFreight',
        'given_number' => 'getGivenNumber',
        'invoice_date' => 'getInvoiceDate',
        'invoice_number' => 'getInvoiceNumber',
        'ocr' => 'getOcr',
        'our_reference' => 'getOurReference',
        'payment_pending' => 'getPaymentPending',
        'project' => 'getProject',
        'round_off_value' => 'getRoundOffValue',
        'sales_type' => 'getSalesType',
        'supplier_invoice_rows' => 'getSupplierInvoiceRows',
        'supplier_name' => 'getSupplierName',
        'supplier_number' => 'getSupplierNumber',
        'total' => 'getTotal',
        'vat' => 'getVat',
        'vat_type' => 'getVatType',
        'voucher_number' => 'getVoucherNumber',
        'voucher_series' => 'getVoucherSeries',
        'voucher_year' => 'getVoucherYear',
        'vouchers' => 'getVouchers',
        'your_reference' => 'getYourReference'
    ];

    /**
     * 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 ACCOUNTING_METHOD_ACCRUAL = 'ACCRUAL';
    public const ACCOUNTING_METHOD_CASH = 'CASH';
    public const SALES_TYPE_STOCK = 'STOCK';
    public const SALES_TYPE_SERVICE = 'SERVICE';
    public const VAT_TYPE_NORMAL = 'NORMAL';
    public const VAT_TYPE_EUINTERNAL = 'EUINTERNAL';
    public const VAT_TYPE_REVERSE = 'REVERSE';

    /**
     * Gets allowable values of the enum
     *
     * @return string[]
     */
    public function getAccountingMethodAllowableValues()
    {
        return [
            self::ACCOUNTING_METHOD_ACCRUAL,
            self::ACCOUNTING_METHOD_CASH,
        ];
    }

    /**
     * Gets allowable values of the enum
     *
     * @return string[]
     */
    public function getSalesTypeAllowableValues()
    {
        return [
            self::SALES_TYPE_STOCK,
            self::SALES_TYPE_SERVICE,
        ];
    }

    /**
     * Gets allowable values of the enum
     *
     * @return string[]
     */
    public function getVatTypeAllowableValues()
    {
        return [
            self::VAT_TYPE_NORMAL,
            self::VAT_TYPE_EUINTERNAL,
            self::VAT_TYPE_REVERSE,
        ];
    }

    /**
     * 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('at_url', $data ?? [], null);
        $this->setIfExists('accounting_method', $data ?? [], null);
        $this->setIfExists('administration_fee', $data ?? [], null);
        $this->setIfExists('balance', $data ?? [], null);
        $this->setIfExists('booked', $data ?? [], null);
        $this->setIfExists('cancelled', $data ?? [], null);
        $this->setIfExists('comments', $data ?? [], null);
        $this->setIfExists('cost_center', $data ?? [], null);
        $this->setIfExists('credit', $data ?? [], null);
        $this->setIfExists('credit_reference', $data ?? [], null);
        $this->setIfExists('currency', $data ?? [], null);
        $this->setIfExists('currency_rate', $data ?? [], null);
        $this->setIfExists('currency_unit', $data ?? [], null);
        $this->setIfExists('disable_payment_file', $data ?? [], null);
        $this->setIfExists('due_date', $data ?? [], null);
        $this->setIfExists('external_invoice_number', $data ?? [], null);
        $this->setIfExists('external_invoice_series', $data ?? [], null);
        $this->setIfExists('final_pay_date', $data ?? [], null);
        $this->setIfExists('freight', $data ?? [], null);
        $this->setIfExists('given_number', $data ?? [], null);
        $this->setIfExists('invoice_date', $data ?? [], null);
        $this->setIfExists('invoice_number', $data ?? [], null);
        $this->setIfExists('ocr', $data ?? [], null);
        $this->setIfExists('our_reference', $data ?? [], null);
        $this->setIfExists('payment_pending', $data ?? [], null);
        $this->setIfExists('project', $data ?? [], null);
        $this->setIfExists('round_off_value', $data ?? [], null);
        $this->setIfExists('sales_type', $data ?? [], null);
        $this->setIfExists('supplier_invoice_rows', $data ?? [], null);
        $this->setIfExists('supplier_name', $data ?? [], null);
        $this->setIfExists('supplier_number', $data ?? [], null);
        $this->setIfExists('total', $data ?? [], null);
        $this->setIfExists('vat', $data ?? [], null);
        $this->setIfExists('vat_type', $data ?? [], null);
        $this->setIfExists('voucher_number', $data ?? [], null);
        $this->setIfExists('voucher_series', $data ?? [], null);
        $this->setIfExists('voucher_year', $data ?? [], null);
        $this->setIfExists('vouchers', $data ?? [], null);
        $this->setIfExists('your_reference', $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 = [];

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

        if (!is_null($this->container['comments']) && (mb_strlen($this->container['comments']) > 1000)) {
            $invalidProperties[] = "invalid value for 'comments', the character length must be smaller than or equal to 1000.";
        }

        if (!is_null($this->container['invoice_number']) && (mb_strlen($this->container['invoice_number']) > 64)) {
            $invalidProperties[] = "invalid value for 'invoice_number', the character length must be smaller than or equal to 64.";
        }

        if (!is_null($this->container['our_reference']) && (mb_strlen($this->container['our_reference']) > 50)) {
            $invalidProperties[] = "invalid value for 'our_reference', the character length must be smaller than or equal to 50.";
        }

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

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

        if (!is_null($this->container['your_reference']) && (mb_strlen($this->container['your_reference']) > 50)) {
            $invalidProperties[] = "invalid value for 'your_reference', the character length must be smaller than or equal to 50.";
        }

        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 at_url
     *
     * @return string|null
     */
    public function getAtUrl()
    {
        return $this->container['at_url'];
    }

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

        return $this;
    }

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

    /**
     * Sets accounting_method
     *
     * @param string|null $accounting_method accounting_method
     *
     * @return self
     */
    public function setAccountingMethod($accounting_method)
    {
        if (is_null($accounting_method)) {
            throw new \InvalidArgumentException('non-nullable accounting_method cannot be null');
        }
        $allowedValues = $this->getAccountingMethodAllowableValues();
        if (!in_array($accounting_method, $allowedValues, true)) {
            throw new \InvalidArgumentException(
                sprintf(
                    "Invalid value '%s' for 'accounting_method', must be one of '%s'",
                    $accounting_method,
                    implode("', '", $allowedValues)
                )
            );
        }
        $this->container['accounting_method'] = $accounting_method;

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

    /**
     * Gets booked
     *
     * @return bool|null
     */
    public function getBooked()
    {
        return $this->container['booked'];
    }

    /**
     * Sets booked
     *
     * @param bool|null $booked booked
     *
     * @return self
     */
    public function setBooked($booked)
    {
        if (is_null($booked)) {
            throw new \InvalidArgumentException('non-nullable booked cannot be null');
        }
        $this->container['booked'] = $booked;

        return $this;
    }

    /**
     * Gets cancelled
     *
     * @return bool|null
     */
    public function getCancelled()
    {
        return $this->container['cancelled'];
    }

    /**
     * Sets cancelled
     *
     * @param bool|null $cancelled cancelled
     *
     * @return self
     */
    public function setCancelled($cancelled)
    {
        if (is_null($cancelled)) {
            throw new \InvalidArgumentException('non-nullable cancelled cannot be null');
        }
        $this->container['cancelled'] = $cancelled;

        return $this;
    }

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

    /**
     * Sets comments
     *
     * @param string|null $comments comments
     *
     * @return self
     */
    public function setComments($comments)
    {
        if (is_null($comments)) {
            throw new \InvalidArgumentException('non-nullable comments cannot be null');
        }
        if ((mb_strlen($comments) > 1000)) {
            throw new \InvalidArgumentException('invalid length for $comments when calling FortnoxLfSupplierInvoiceSingleItem., must be smaller than or equal to 1000.');
        }

        $this->container['comments'] = $comments;

        return $this;
    }

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

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

        return $this;
    }

    /**
     * Gets credit
     *
     * @return bool|null
     */
    public function getCredit()
    {
        return $this->container['credit'];
    }

    /**
     * Sets credit
     *
     * @param bool|null $credit credit
     *
     * @return self
     */
    public function setCredit($credit)
    {
        if (is_null($credit)) {
            throw new \InvalidArgumentException('non-nullable credit cannot be null');
        }
        $this->container['credit'] = $credit;

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

    /**
     * Sets currency_unit
     *
     * @param float|null $currency_unit currency_unit
     *
     * @return self
     */
    public function setCurrencyUnit($currency_unit)
    {
        if (is_null($currency_unit)) {
            throw new \InvalidArgumentException('non-nullable currency_unit cannot be null');
        }
        $this->container['currency_unit'] = $currency_unit;

        return $this;
    }

    /**
     * Gets disable_payment_file
     *
     * @return bool|null
     */
    public function getDisablePaymentFile()
    {
        return $this->container['disable_payment_file'];
    }

    /**
     * Sets disable_payment_file
     *
     * @param bool|null $disable_payment_file disable_payment_file
     *
     * @return self
     */
    public function setDisablePaymentFile($disable_payment_file)
    {
        if (is_null($disable_payment_file)) {
            throw new \InvalidArgumentException('non-nullable disable_payment_file cannot be null');
        }
        $this->container['disable_payment_file'] = $disable_payment_file;

        return $this;
    }

    /**
     * Gets due_date
     *
     * @return \DateTime|null
     */
    public function getDueDate()
    {
        return $this->container['due_date'];
    }

    /**
     * Sets due_date
     *
     * @param \DateTime|null $due_date due_date
     *
     * @return self
     */
    public function setDueDate($due_date)
    {
        if (is_null($due_date)) {
            throw new \InvalidArgumentException('non-nullable due_date cannot be null');
        }
        $this->container['due_date'] = $due_date;

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

    /**
     * Gets final_pay_date
     *
     * @return \DateTime|null
     */
    public function getFinalPayDate()
    {
        return $this->container['final_pay_date'];
    }

    /**
     * Sets final_pay_date
     *
     * @param \DateTime|null $final_pay_date final_pay_date
     *
     * @return self
     */
    public function setFinalPayDate($final_pay_date)
    {
        if (is_null($final_pay_date)) {
            throw new \InvalidArgumentException('non-nullable final_pay_date cannot be null');
        }
        $this->container['final_pay_date'] = $final_pay_date;

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

    /**
     * Gets invoice_date
     *
     * @return \DateTime|null
     */
    public function getInvoiceDate()
    {
        return $this->container['invoice_date'];
    }

    /**
     * Sets invoice_date
     *
     * @param \DateTime|null $invoice_date invoice_date
     *
     * @return self
     */
    public function setInvoiceDate($invoice_date)
    {
        if (is_null($invoice_date)) {
            throw new \InvalidArgumentException('non-nullable invoice_date cannot be null');
        }
        $this->container['invoice_date'] = $invoice_date;

        return $this;
    }

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

    /**
     * Sets invoice_number
     *
     * @param string|null $invoice_number invoice_number
     *
     * @return self
     */
    public function setInvoiceNumber($invoice_number)
    {
        if (is_null($invoice_number)) {
            throw new \InvalidArgumentException('non-nullable invoice_number cannot be null');
        }
        if ((mb_strlen($invoice_number) > 64)) {
            throw new \InvalidArgumentException('invalid length for $invoice_number when calling FortnoxLfSupplierInvoiceSingleItem., must be smaller than or equal to 64.');
        }

        $this->container['invoice_number'] = $invoice_number;

        return $this;
    }

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

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

        return $this;
    }

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

    /**
     * Sets our_reference
     *
     * @param string|null $our_reference our_reference
     *
     * @return self
     */
    public function setOurReference($our_reference)
    {
        if (is_null($our_reference)) {
            throw new \InvalidArgumentException('non-nullable our_reference cannot be null');
        }
        if ((mb_strlen($our_reference) > 50)) {
            throw new \InvalidArgumentException('invalid length for $our_reference when calling FortnoxLfSupplierInvoiceSingleItem., must be smaller than or equal to 50.');
        }

        $this->container['our_reference'] = $our_reference;

        return $this;
    }

    /**
     * Gets payment_pending
     *
     * @return bool|null
     */
    public function getPaymentPending()
    {
        return $this->container['payment_pending'];
    }

    /**
     * Sets payment_pending
     *
     * @param bool|null $payment_pending payment_pending
     *
     * @return self
     */
    public function setPaymentPending($payment_pending)
    {
        if (is_null($payment_pending)) {
            throw new \InvalidArgumentException('non-nullable payment_pending cannot be null');
        }
        $this->container['payment_pending'] = $payment_pending;

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

    /**
     * Sets sales_type
     *
     * @param string|null $sales_type sales_type
     *
     * @return self
     */
    public function setSalesType($sales_type)
    {
        if (is_null($sales_type)) {
            throw new \InvalidArgumentException('non-nullable sales_type cannot be null');
        }
        $allowedValues = $this->getSalesTypeAllowableValues();
        if (!in_array($sales_type, $allowedValues, true)) {
            throw new \InvalidArgumentException(
                sprintf(
                    "Invalid value '%s' for 'sales_type', must be one of '%s'",
                    $sales_type,
                    implode("', '", $allowedValues)
                )
            );
        }
        $this->container['sales_type'] = $sales_type;

        return $this;
    }

    /**
     * Gets supplier_invoice_rows
     *
     * @return \Fortnox\Model\FortnoxLfSupplierInvoiceRowSingleItem[]|null
     */
    public function getSupplierInvoiceRows()
    {
        return $this->container['supplier_invoice_rows'];
    }

    /**
     * Sets supplier_invoice_rows
     *
     * @param \Fortnox\Model\FortnoxLfSupplierInvoiceRowSingleItem[]|null $supplier_invoice_rows supplier_invoice_rows
     *
     * @return self
     */
    public function setSupplierInvoiceRows($supplier_invoice_rows)
    {
        if (is_null($supplier_invoice_rows)) {
            throw new \InvalidArgumentException('non-nullable supplier_invoice_rows cannot be null');
        }
        $this->container['supplier_invoice_rows'] = $supplier_invoice_rows;

        return $this;
    }

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

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

        return $this;
    }

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

    /**
     * Sets supplier_number
     *
     * @param string $supplier_number supplier_number
     *
     * @return self
     */
    public function setSupplierNumber($supplier_number)
    {
        if (is_null($supplier_number)) {
            throw new \InvalidArgumentException('non-nullable supplier_number cannot be null');
        }
        $this->container['supplier_number'] = $supplier_number;

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

    /**
     * Sets vat_type
     *
     * @param string|null $vat_type vat_type
     *
     * @return self
     */
    public function setVatType($vat_type)
    {
        if (is_null($vat_type)) {
            throw new \InvalidArgumentException('non-nullable vat_type cannot be null');
        }
        $allowedValues = $this->getVatTypeAllowableValues();
        if (!in_array($vat_type, $allowedValues, true)) {
            throw new \InvalidArgumentException(
                sprintf(
                    "Invalid value '%s' for 'vat_type', must be one of '%s'",
                    $vat_type,
                    implode("', '", $allowedValues)
                )
            );
        }
        $this->container['vat_type'] = $vat_type;

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

    /**
     * Gets vouchers
     *
     * @return \Fortnox\Model\FortnoxLfVoucherReferenceSingleItem[]|null
     */
    public function getVouchers()
    {
        return $this->container['vouchers'];
    }

    /**
     * Sets vouchers
     *
     * @param \Fortnox\Model\FortnoxLfVoucherReferenceSingleItem[]|null $vouchers vouchers
     *
     * @return self
     */
    public function setVouchers($vouchers)
    {
        if (is_null($vouchers)) {
            throw new \InvalidArgumentException('non-nullable vouchers cannot be null');
        }
        $this->container['vouchers'] = $vouchers;

        return $this;
    }

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

    /**
     * Sets your_reference
     *
     * @param string|null $your_reference your_reference
     *
     * @return self
     */
    public function setYourReference($your_reference)
    {
        if (is_null($your_reference)) {
            throw new \InvalidArgumentException('non-nullable your_reference cannot be null');
        }
        if ((mb_strlen($your_reference) > 50)) {
            throw new \InvalidArgumentException('invalid length for $your_reference when calling FortnoxLfSupplierInvoiceSingleItem., must be smaller than or equal to 50.');
        }

        $this->container['your_reference'] = $your_reference;

        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));
    }
}


