<?php

declare(strict_types=1);

namespace OCA\Mitgliederverwaltung\Db;

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

/**
 * Fee record entity mapping all columns from oc_mv_fee_records.
 *
 * Each record represents a calculated (or manually overridden) fee
 * for a specific member in a specific year.
 *
 * Part of Issue #42.
 *
 * @method int getMemberId()
 * @method void setMemberId(int $memberId)
 * @method int getYear()
 * @method void setYear(int $year)
 * @method string|null getAmount()
 * @method void setAmount(?string $amount)
 * @method string|null getRuleSnapshotJson()
 * @method void setRuleSnapshotJson(?string $ruleSnapshotJson)
 * @method bool getManuellAngepasst()
 * @method void setManuellAngepasst(bool $manuellAngepasst)
 * @method bool getPaid()
 * @method void setPaid(bool $paid)
 * @method string|null getPaymentDate()
 * @method void setPaymentDate(?string $paymentDate)
 * @method string|null getNotes()
 * @method void setNotes(?string $notes)
 * @method string getCreatedAt()
 * @method void setCreatedAt(string $createdAt)
 * @method string getUpdatedAt()
 * @method void setUpdatedAt(string $updatedAt)
 */
class FeeRecord extends Entity implements JsonSerializable {

    protected int $memberId = 0;
    protected int $year = 0;
    protected ?string $amount = null;
    protected ?string $ruleSnapshotJson = null;
    protected bool $manuellAngepasst = false;
    protected bool $paid = false;
    protected ?string $paymentDate = null;
    protected ?string $notes = null;
    protected string $createdAt = '';
    protected string $updatedAt = '';

    public function __construct() {
        $this->addType('id', 'integer');
        $this->addType('memberId', 'integer');
        $this->addType('year', 'integer');
        $this->addType('manuellAngepasst', 'boolean');
        $this->addType('paid', 'boolean');
    }

    public function jsonSerialize(): array {
        return [
            'id' => $this->id,
            'memberId' => $this->memberId,
            'year' => $this->year,
            'amount' => $this->amount,
            'ruleSnapshotJson' => $this->ruleSnapshotJson,
            'manuellAngepasst' => $this->manuellAngepasst,
            'paid' => $this->paid,
            'paymentDate' => $this->paymentDate,
            'notes' => $this->notes,
            'createdAt' => $this->createdAt,
            'updatedAt' => $this->updatedAt,
        ];
    }
}
