<?php

/**
 * Main Receipt model.
 *
 * @package northmill-online-shared
 */
declare (strict_types=1);
namespace Northmill_Online_Shared_Sync\Northmill_Online_Shared\Abstracts\Hub_API\Models\Receipts;

use JsonSerializable;
use Northmill_Online_Shared_Sync\Northmill_Online_Shared\Helpers\General_Helpers;
/**
 * Class Receipt_Model
 */
class Receipt_Model implements JsonSerializable
{
    /**
     * Receipt number.
     *
     * @var int
     */
    protected int $ReceiptNumber;
    /**
     * Origin of the receipt.
     *
     * @var string
     */
    protected string $Origin;
    /**
     * Receipt ID.
     * This is currently never set in WooCommerce.
     *
     * @var string|null
     */
    protected ?string $Id;
    /**
     * Type of receipt.
     * Default: 'Online'
     *
     * @var string
     */
    protected string $ReceiptType;
    /**
     * Internal note for the receipt.
     * Can be null.
     * Or contain refund reason, for instance.
     *
     * @var string|null
     */
    protected ?string $InternalNote;
    /**
     * Date of the transaction.
     * Format: Y-m-d\TH:i:s\.\0\0\0\Z
     *
     * @var string
     */
    protected string $TransactionDate;
    /**
     * Cashier name, who is responsible for the receipt.
     * This doesn't exist in WooCommerce, so we default to null.
     *
     * @var string|null
     */
    protected ?string $CashierName;
    /**
     * Total receipt price including VAT.
     * Formatted as a string, should only contain numbers and a dot.
     * Two decimals.
     *
     * @var string
     */
    protected string $TotalPriceIncVat;
    /**
     * Total receipt price excluding VAT.
     * Formatted as a string, should only contain numbers and a dot.
     * Two decimals.
     *
     * @var string
     */
    protected string $TotalPriceExVat;
    /**
     * Total VAT for the receipt.
     * Formatted as a string, should only contain numbers and a dot.
     *
     * @var string
     */
    protected string $TotalVat;
    /**
     * Whether stock management should be done for the receipt.
     *
     * @var bool
     */
    protected bool $DoStockMgmt;
    /**
     * Merchant information.
     *
     * @var Receipt_Merchant_Model
     */
    protected Receipt_Merchant_Model $Merchant;
    /**
     * Rounding information.
     *
     * @var null|int[]
     */
    protected ?array $Rounding;
    /**
     * Control unit information.
     *
     * @var string[]
     */
    protected ?array $ControlUnit;
    /**
     * Customers for the receipt.
     *
     * @var Receipt_Customer_Model[]
     */
    protected array $Customers;
    /**
     * Articles for the receipt.
     *
     * @var Receipt_Article_Model[]
     */
    protected array $Articles;
    /**
     * Payments for the receipt.
     *
     * @var Receipt_Payment_Model[]
     */
    protected array $Payments;
    /**
     * VAT for the receipt.
     *
     * @var Receipt_Vat_Model[]
     */
    protected array $Vat;
    /**
     * Orders references for the receipt.
     *
     * @var Receipt_Order_Reference_Model[]
     */
    protected array $Orders;
    /**
     * Discounts for the receipt.
     *
     * @var Receipt_Discount_Model[]
     */
    protected array $Discounts;
    /**
     * Recipients for the receipt.
     *
     * @var array
     */
    protected array $Recipients;
    /**
     * Text rows for the receipt.
     *
     * @var array|null
     */
    protected ?array $TextRows = null;
    /**
     * Client details for the receipt.
     *
     * @var string[]|null
     */
    protected ?array $ClientDetails = null;
    /**
     * Voucher for the receipt.
     *
     * @var Receipt_Voucher_Model|null
     */
    protected ?Receipt_Voucher_Model $Voucher = null;
    public function __construct(int $receipt_number, ?string $internal_note, string $transaction_date, string|float $total_price_inc_vat, string|float $total_price_ex_vat, string|float $total_vat, bool $do_stock_management, Receipt_Merchant_Model $merchant, array $customers, array $articles, array $payments, array $orders, array $vat, ?Receipt_Voucher_Model $voucher, ?array $text_rows, string $receipt_type, string $origin, ?string $id, ?string $cashier_name, ?array $rounding, ?array $control_unit, array $discounts, array $recipients, ?array $client_details)
    {
        $this->ReceiptNumber = $receipt_number;
        $this->InternalNote = $internal_note;
        $this->TransactionDate = $transaction_date;
        $this->TotalPriceIncVat = General_Helpers::round_and_format_number($total_price_inc_vat);
        $this->TotalPriceExVat = General_Helpers::round_and_format_number($total_price_ex_vat);
        $this->TotalVat = General_Helpers::round_and_format_number($total_vat);
        $this->DoStockMgmt = $do_stock_management;
        $this->Merchant = $merchant;
        $this->Customers = $customers;
        $this->Articles = $articles;
        $this->Payments = $payments;
        $this->Orders = $orders;
        $this->Vat = $vat;
        $this->Voucher = $voucher;
        $this->TextRows = $text_rows;
        $this->ReceiptType = $receipt_type;
        $this->Origin = $origin;
        $this->Id = $id;
        $this->CashierName = $cashier_name;
        $this->Rounding = $rounding;
        $this->ControlUnit = $control_unit;
        $this->Discounts = $discounts;
        $this->Recipients = $recipients;
        $this->ClientDetails = $client_details;
    }
    public function get_voucher(): ?Receipt_Voucher_Model
    {
        return $this->Voucher;
    }
    public function get_articles(): array
    {
        return $this->Articles;
    }
    public function jsonSerialize(): array
    {
        return array('ReceiptNumber' => $this->ReceiptNumber, 'Origin' => $this->Origin, 'Id' => $this->Id, 'ReceiptType' => $this->ReceiptType, 'InternalNote' => $this->InternalNote, 'TransactionDate' => $this->TransactionDate, 'CashierName' => $this->CashierName, 'TotalPriceIncVat' => $this->TotalPriceIncVat, 'TotalPriceExVat' => $this->TotalPriceExVat, 'TotalVat' => $this->TotalVat, 'DoStockMgmt' => $this->DoStockMgmt, 'Merchant' => $this->Merchant, 'Rounding' => $this->Rounding, 'ControlUnit' => $this->ControlUnit, 'Customers' => $this->Customers, 'Articles' => $this->Articles, 'Payments' => $this->Payments, 'Vat' => $this->Vat, 'Orders' => $this->Orders, 'Discounts' => $this->Discounts, 'Recipients' => $this->Recipients, 'TextRows' => $this->TextRows, 'ClientDetails' => $this->ClientDetails, 'Voucher' => $this->Voucher);
    }
}
