<?php

declare(strict_types=1);

namespace CpCreation\VitiCore\Cart\Model\Payment;

trait EstimatedTransactionFeeTrait
{
    private ?float $estimatedTransactionFeePercent = null;

    private ?float $estimatedTransactionFeeFixed = null;

    public function getEstimatedTransactionFeePercent(): ?float
    {
        return $this->estimatedTransactionFeePercent;
    }

    public function setEstimatedTransactionFeePercent(?float $estimatedTransactionFeePercent): void
    {
        $this->estimatedTransactionFeePercent = null !== $estimatedTransactionFeePercent
            ? max(0.0, round($estimatedTransactionFeePercent, 4))
            : null;
    }

    public function getEstimatedTransactionFeeFixed(): ?float
    {
        return $this->estimatedTransactionFeeFixed;
    }

    public function setEstimatedTransactionFeeFixed(?float $estimatedTransactionFeeFixed): void
    {
        $this->estimatedTransactionFeeFixed = null !== $estimatedTransactionFeeFixed
            ? max(0.0, round($estimatedTransactionFeeFixed, 2))
            : null;
    }
}
