<?php
/**
 * FortnoxKfInvoiceRowV2SinglePayloadItem
 *
 * 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;

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

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

    /**
      * Array of property to type mappings. Used for (de)serialization
      *
      * @var string[]
      */
    protected static $openAPITypes = [
        'account_number' => 'int',
        'article_number' => 'string',
        'bundle' => '\Fortnox\Model\FortnoxKfBundleInstanceSinglePayloadItem',
        'cost' => 'float',
        'cost_center' => 'string',
        'delivered_quantity' => 'string',
        'description' => 'string',
        'discount' => 'float',
        'discount_type' => 'string',
        'house_work' => 'bool',
        'house_work_hours_to_report' => 'int',
        'house_work_type' => 'string',
        'price' => 'float',
        'project' => 'string',
        'row_id' => 'int',
        'stock_point_code' => 'string',
        'unit' => 'string',
        'vat' => 'int',
        'vat_code' => '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 = [
        'account_number' => 'int32',
        'article_number' => null,
        'bundle' => null,
        'cost' => 'float',
        'cost_center' => null,
        'delivered_quantity' => null,
        'description' => null,
        'discount' => 'double',
        'discount_type' => null,
        'house_work' => null,
        'house_work_hours_to_report' => 'int32',
        'house_work_type' => null,
        'price' => 'double',
        'project' => null,
        'row_id' => 'int32',
        'stock_point_code' => null,
        'unit' => null,
        'vat' => 'int32',
        'vat_code' => null
    ];

    /**
      * Array of nullable properties. Used for (de)serialization
      *
      * @var boolean[]
      */
    protected static array $openAPINullables = [
        'account_number' => false,
        'article_number' => false,
        'bundle' => false,
        'cost' => true,
        'cost_center' => true,
        'delivered_quantity' => false,
        'description' => false,
        'discount' => false,
        'discount_type' => false,
        'house_work' => false,
        'house_work_hours_to_report' => true,
        'house_work_type' => false,
        'price' => false,
        'project' => false,
        'row_id' => false,
        'stock_point_code' => false,
        'unit' => false,
        'vat' => false,
        'vat_code' => 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 = [
        'account_number' => 'AccountNumber',
        'article_number' => 'ArticleNumber',
        'bundle' => 'Bundle',
        'cost' => 'Cost',
        'cost_center' => 'CostCenter',
        'delivered_quantity' => 'DeliveredQuantity',
        'description' => 'Description',
        'discount' => 'Discount',
        'discount_type' => 'DiscountType',
        'house_work' => 'HouseWork',
        'house_work_hours_to_report' => 'HouseWorkHoursToReport',
        'house_work_type' => 'HouseWorkType',
        'price' => 'Price',
        'project' => 'Project',
        'row_id' => 'RowId',
        'stock_point_code' => 'StockPointCode',
        'unit' => 'Unit',
        'vat' => 'VAT',
        'vat_code' => 'VATCode'
    ];

    /**
     * Array of attributes to setter functions (for deserialization of responses)
     *
     * @var string[]
     */
    protected static $setters = [
        'account_number' => 'setAccountNumber',
        'article_number' => 'setArticleNumber',
        'bundle' => 'setBundle',
        'cost' => 'setCost',
        'cost_center' => 'setCostCenter',
        'delivered_quantity' => 'setDeliveredQuantity',
        'description' => 'setDescription',
        'discount' => 'setDiscount',
        'discount_type' => 'setDiscountType',
        'house_work' => 'setHouseWork',
        'house_work_hours_to_report' => 'setHouseWorkHoursToReport',
        'house_work_type' => 'setHouseWorkType',
        'price' => 'setPrice',
        'project' => 'setProject',
        'row_id' => 'setRowId',
        'stock_point_code' => 'setStockPointCode',
        'unit' => 'setUnit',
        'vat' => 'setVat',
        'vat_code' => 'setVatCode'
    ];

    /**
     * Array of attributes to getter functions (for serialization of requests)
     *
     * @var string[]
     */
    protected static $getters = [
        'account_number' => 'getAccountNumber',
        'article_number' => 'getArticleNumber',
        'bundle' => 'getBundle',
        'cost' => 'getCost',
        'cost_center' => 'getCostCenter',
        'delivered_quantity' => 'getDeliveredQuantity',
        'description' => 'getDescription',
        'discount' => 'getDiscount',
        'discount_type' => 'getDiscountType',
        'house_work' => 'getHouseWork',
        'house_work_hours_to_report' => 'getHouseWorkHoursToReport',
        'house_work_type' => 'getHouseWorkType',
        'price' => 'getPrice',
        'project' => 'getProject',
        'row_id' => 'getRowId',
        'stock_point_code' => 'getStockPointCode',
        'unit' => 'getUnit',
        'vat' => 'getVat',
        'vat_code' => 'getVatCode'
    ];

    /**
     * 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 DISCOUNT_TYPE_AMOUNT = 'AMOUNT';
    public const DISCOUNT_TYPE_PERCENT = 'PERCENT';
    public const HOUSE_WORK_TYPE_CONSTRUCTION = 'CONSTRUCTION';
    public const HOUSE_WORK_TYPE_ELECTRICITY = 'ELECTRICITY';
    public const HOUSE_WORK_TYPE_GLASSMETALWORK = 'GLASSMETALWORK';
    public const HOUSE_WORK_TYPE_GROUNDDRAINAGEWORK = 'GROUNDDRAINAGEWORK';
    public const HOUSE_WORK_TYPE_MASONRY = 'MASONRY';
    public const HOUSE_WORK_TYPE_PAINTINGWALLPAPERING = 'PAINTINGWALLPAPERING';
    public const HOUSE_WORK_TYPE_HVAC = 'HVAC';
    public const HOUSE_WORK_TYPE_MAJORAPPLIANCEREPAIR = 'MAJORAPPLIANCEREPAIR';
    public const HOUSE_WORK_TYPE_MOVINGSERVICES = 'MOVINGSERVICES';
    public const HOUSE_WORK_TYPE_ITSERVICES = 'ITSERVICES';
    public const HOUSE_WORK_TYPE_CLEANING = 'CLEANING';
    public const HOUSE_WORK_TYPE_TEXTILECLOTHING = 'TEXTILECLOTHING';
    public const HOUSE_WORK_TYPE_SNOWPLOWING = 'SNOWPLOWING';
    public const HOUSE_WORK_TYPE_GARDENING = 'GARDENING';
    public const HOUSE_WORK_TYPE_BABYSITTING = 'BABYSITTING';
    public const HOUSE_WORK_TYPE_OTHERCARE = 'OTHERCARE';
    public const HOUSE_WORK_TYPE_OTHERCOSTS = 'OTHERCOSTS';
    public const HOUSE_WORK_TYPE_SOLARCELLS = 'SOLARCELLS';
    public const HOUSE_WORK_TYPE_STORAGESELFPRODUCEDELECTRICITY = 'STORAGESELFPRODUCEDELECTRICITY';
    public const HOUSE_WORK_TYPE_CHARGINGSTATIONELECTRICVEHICLE = 'CHARGINGSTATIONELECTRICVEHICLE';
    public const HOUSE_WORK_TYPE_HOMEMAINTENANCE = 'HOMEMAINTENANCE';
    public const HOUSE_WORK_TYPE_FURNISHING = 'FURNISHING';
    public const HOUSE_WORK_TYPE_TRANSPORTATIONSERVICES = 'TRANSPORTATIONSERVICES';
    public const HOUSE_WORK_TYPE_WASHINGANDCAREOFCLOTHING = 'WASHINGANDCAREOFCLOTHING';

    /**
     * Gets allowable values of the enum
     *
     * @return string[]
     */
    public function getDiscountTypeAllowableValues()
    {
        return [
            self::DISCOUNT_TYPE_AMOUNT,
            self::DISCOUNT_TYPE_PERCENT,
        ];
    }

    /**
     * Gets allowable values of the enum
     *
     * @return string[]
     */
    public function getHouseWorkTypeAllowableValues()
    {
        return [
            self::HOUSE_WORK_TYPE_CONSTRUCTION,
            self::HOUSE_WORK_TYPE_ELECTRICITY,
            self::HOUSE_WORK_TYPE_GLASSMETALWORK,
            self::HOUSE_WORK_TYPE_GROUNDDRAINAGEWORK,
            self::HOUSE_WORK_TYPE_MASONRY,
            self::HOUSE_WORK_TYPE_PAINTINGWALLPAPERING,
            self::HOUSE_WORK_TYPE_HVAC,
            self::HOUSE_WORK_TYPE_MAJORAPPLIANCEREPAIR,
            self::HOUSE_WORK_TYPE_MOVINGSERVICES,
            self::HOUSE_WORK_TYPE_ITSERVICES,
            self::HOUSE_WORK_TYPE_CLEANING,
            self::HOUSE_WORK_TYPE_TEXTILECLOTHING,
            self::HOUSE_WORK_TYPE_SNOWPLOWING,
            self::HOUSE_WORK_TYPE_GARDENING,
            self::HOUSE_WORK_TYPE_BABYSITTING,
            self::HOUSE_WORK_TYPE_OTHERCARE,
            self::HOUSE_WORK_TYPE_OTHERCOSTS,
            self::HOUSE_WORK_TYPE_SOLARCELLS,
            self::HOUSE_WORK_TYPE_STORAGESELFPRODUCEDELECTRICITY,
            self::HOUSE_WORK_TYPE_CHARGINGSTATIONELECTRICVEHICLE,
            self::HOUSE_WORK_TYPE_HOMEMAINTENANCE,
            self::HOUSE_WORK_TYPE_FURNISHING,
            self::HOUSE_WORK_TYPE_TRANSPORTATIONSERVICES,
            self::HOUSE_WORK_TYPE_WASHINGANDCAREOFCLOTHING,
        ];
    }

    /**
     * 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('account_number', $data ?? [], null);
        $this->setIfExists('article_number', $data ?? [], null);
        $this->setIfExists('bundle', $data ?? [], null);
        $this->setIfExists('cost', $data ?? [], null);
        $this->setIfExists('cost_center', $data ?? [], null);
        $this->setIfExists('delivered_quantity', $data ?? [], null);
        $this->setIfExists('description', $data ?? [], null);
        $this->setIfExists('discount', $data ?? [], null);
        $this->setIfExists('discount_type', $data ?? [], null);
        $this->setIfExists('house_work', $data ?? [], null);
        $this->setIfExists('house_work_hours_to_report', $data ?? [], null);
        $this->setIfExists('house_work_type', $data ?? [], null);
        $this->setIfExists('price', $data ?? [], null);
        $this->setIfExists('project', $data ?? [], null);
        $this->setIfExists('row_id', $data ?? [], null);
        $this->setIfExists('stock_point_code', $data ?? [], null);
        $this->setIfExists('unit', $data ?? [], null);
        $this->setIfExists('vat', $data ?? [], null);
        $this->setIfExists('vat_code', $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 (!is_null($this->container['account_number']) && ($this->container['account_number'] > 9999)) {
            $invalidProperties[] = "invalid value for 'account_number', must be smaller than or equal to 9999.";
        }

        if (!is_null($this->container['account_number']) && ($this->container['account_number'] < 1000)) {
            $invalidProperties[] = "invalid value for 'account_number', must be bigger than or equal to 1000.";
        }

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

        if (!is_null($this->container['cost']) && ($this->container['cost'] < -9999999999)) {
            $invalidProperties[] = "invalid value for 'cost', must be bigger than or equal to -9999999999.";
        }

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

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

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

        if (!is_null($this->container['house_work_hours_to_report']) && ($this->container['house_work_hours_to_report'] < 0)) {
            $invalidProperties[] = "invalid value for 'house_work_hours_to_report', must be bigger than or equal to 0.";
        }

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

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

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

    /**
     * Sets account_number
     *
     * @param int|null $account_number account_number
     *
     * @return self
     */
    public function setAccountNumber($account_number)
    {
        if (is_null($account_number)) {
            throw new \InvalidArgumentException('non-nullable account_number cannot be null');
        }

        if (($account_number > 9999)) {
            throw new \InvalidArgumentException('invalid value for $account_number when calling FortnoxKfInvoiceRowV2SinglePayloadItem., must be smaller than or equal to 9999.');
        }
        if (($account_number < 1000)) {
            throw new \InvalidArgumentException('invalid value for $account_number when calling FortnoxKfInvoiceRowV2SinglePayloadItem., must be bigger than or equal to 1000.');
        }

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

    /**
     * Sets cost
     *
     * @param float|null $cost cost
     *
     * @return self
     */
    public function setCost($cost)
    {
        if (is_null($cost)) {
            array_push($this->openAPINullablesSetToNull, 'cost');
        } else {
            $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
            $index = array_search('cost', $nullablesSetToNull);
            if ($index !== FALSE) {
                unset($nullablesSetToNull[$index]);
                $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
            }
        }

        if (!is_null($cost) && ($cost > 9999999999)) {
            throw new \InvalidArgumentException('invalid value for $cost when calling FortnoxKfInvoiceRowV2SinglePayloadItem., must be smaller than or equal to 9999999999.');
        }
        if (!is_null($cost) && ($cost < -9999999999)) {
            throw new \InvalidArgumentException('invalid value for $cost when calling FortnoxKfInvoiceRowV2SinglePayloadItem., must be bigger than or equal to -9999999999.');
        }

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

        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)) {
            array_push($this->openAPINullablesSetToNull, 'cost_center');
        } else {
            $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
            $index = array_search('cost_center', $nullablesSetToNull);
            if ($index !== FALSE) {
                unset($nullablesSetToNull[$index]);
                $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
            }
        }
        $this->container['cost_center'] = $cost_center;

        return $this;
    }

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

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

        return $this;
    }

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

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

    /**
     * Sets house_work_hours_to_report
     *
     * @param int|null $house_work_hours_to_report house_work_hours_to_report
     *
     * @return self
     */
    public function setHouseWorkHoursToReport($house_work_hours_to_report)
    {
        if (is_null($house_work_hours_to_report)) {
            array_push($this->openAPINullablesSetToNull, 'house_work_hours_to_report');
        } else {
            $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
            $index = array_search('house_work_hours_to_report', $nullablesSetToNull);
            if ($index !== FALSE) {
                unset($nullablesSetToNull[$index]);
                $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
            }
        }

        if (!is_null($house_work_hours_to_report) && ($house_work_hours_to_report > 999)) {
            throw new \InvalidArgumentException('invalid value for $house_work_hours_to_report when calling FortnoxKfInvoiceRowV2SinglePayloadItem., must be smaller than or equal to 999.');
        }
        if (!is_null($house_work_hours_to_report) && ($house_work_hours_to_report < 0)) {
            throw new \InvalidArgumentException('invalid value for $house_work_hours_to_report when calling FortnoxKfInvoiceRowV2SinglePayloadItem., must be bigger than or equal to 0.');
        }

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

        return $this;
    }

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

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

        return $this;
    }

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

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

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

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

        return $this;
    }

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

    /**
     * Sets vat
     *
     * @param int|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_code
     *
     * @return string|null
     */
    public function getVatCode()
    {
        return $this->container['vat_code'];
    }

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

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


