<?php

declare( strict_types=1 );

namespace Brightfern\Invoice\Input;

/**
 * A document-level charge or allowance derived from the order: shipping (charge),
 * fees (charge, or allowance if negative), and order-level coupon discounts not
 * attributable to a single line (allowance).
 *
 * Each carries its own VAT rate so it lands in the correct VAT breakdown row.
 * `amount` is always positive net; `isCharge` gives the direction.
 */
final class OrderCharge {
	public function __construct(
		public bool $isCharge,
		public float $amount,
		public float $taxRatePercent,
		public string $reasonText = '',
		public string $reasonCode = '',
	) {}

	public static function shipping( float $amount, float $taxRatePercent ): self {
		// UNCL7161 "SAA" = shipping & handling. Shipping is a charge.
		return new self( true, $amount, $taxRatePercent, 'Shipping', 'SAA' );
	}
}
