<?php

namespace Shm\ShmPayment\TBankPayment;

class TBankReceiptItem
{

    public $name;
    public $price;
    public $quantity;

    public static function create()
    {
        return new self();
    }

    public function __construct() {}


    public function name($name)
    {
        $this->name = $name;
        return $this;
    }

    public function price($price)
    {
        //Перевод в копейки
        $this->price = $price * 100;
        return $this;
    }

    public function quantity($quantity)
    {
        $this->quantity = $quantity;
        return $this;
    }

    public function amount()
    {
        return $this->price * $this->quantity;
    }

    public function toArray()
    {
        return [
            "Name" => $this->name,
            "Price" => $this->price,
            "Quantity" => $this->quantity,
            "Amount" => $this->amount(),
            "Tax" => TBankPayment::$terminalTaxRate,
        ];
    }
}
