<?php

declare(strict_types=1);

namespace OCA\Mitgliederverwaltung\Db;

use JsonSerializable;
use OCP\AppFramework\Db\Entity;

/**
 * Stock variant entity mapping all columns from oc_mv_inventory_stock_variants.
 *
 * Part of Issue #165 (Inventory Tracking).
 *
 * @method int|null getId()
 * @method void setId(int $id)
 * @method int getStockItemId()
 * @method void setStockItemId(int $stockItemId)
 * @method string getLabel()
 * @method void setLabel(string $label)
 * @method int getAmount()
 * @method void setAmount(int $amount)
 * @method string getCost()
 * @method void setCost(string $cost)
 * @method int getMinThreshold()
 * @method void setMinThreshold(int $minThreshold)
 */
class StockVariant extends Entity implements JsonSerializable {

    protected int $id = 0;
    protected int $stockItemId = 0;
    protected string $label = '';
    protected int $amount = 0;
    protected string $cost = '0.00';
    protected int $minThreshold = 0;

    public function __construct() {
        $this->addType('id', 'integer');
        $this->addType('stockItemId', 'integer');
        $this->addType('amount', 'integer');
        $this->addType('minThreshold', 'integer');
    }

    public function jsonSerialize(): array {
        return [
            'id' => $this->id,
            'stock_item_id' => $this->stockItemId,
            'label' => $this->label,
            'amount' => $this->amount,
            'cost' => $this->cost,
            'min_threshold' => $this->minThreshold,
        ];
    }
}
