<?php

declare( strict_types=1 );

namespace Brightfern\Invoice\Model;

/**
 * An invoice line (BG-25).
 *
 *   BT-126  Line identifier.
 *   BT-127  Line note.
 *   BT-129  Invoiced quantity.
 *   BT-130  Unit of measure code (UN/ECE Rec 20; default "C62" = one/piece).
 *   BT-131  Line net amount (after line allowances/charges, EXCLUDING VAT).
 *   BT-146  Item net price (the price the quantity is multiplied by).
 *   BT-149  Item price base quantity (default 1).
 *   BT-153  Item name.
 *   BT-154  Item description.
 *   BT-151  Line VAT category code.
 *   BT-152  Line VAT rate.
 *   BT-155  Seller's item identifier.
 *   BT-157  Standard item identifier (e.g. GTIN) + scheme.
 *
 * Invariant enforced by the mapper: lineExtensionAmount == round2(
 *   netPrice / baseQuantity * quantity  +  Σ line allowance/charge signed
 * ). The serializer trusts this; the validator re-checks it (BR-24 etc.).
 */
final class InvoiceLine {
	public string $id = '';
	public string $note = '';
	public float $quantity = 1.0;
	public string $unitCode = 'C62';
	public float $lineExtensionAmount = 0.0; // BT-131.
	public float $netPriceAmount = 0.0;      // BT-146.
	public float $baseQuantity = 1.0;        // BT-149.

	public string $name = '';                // BT-153.
	public string $description = '';         // BT-154.

	public string $vatCategoryCode = '';     // BT-151.
	public float $vatPercent = 0.0;          // BT-152.

	public string $sellerItemId = '';        // BT-155 (e.g. SKU).
	public string $standardItemId = '';      // BT-157 (e.g. GTIN).
	public string $standardItemScheme = '';  // ICD scheme for BT-157, e.g. "0160".

	/** @var AllowanceCharge[] Line-level allowances/charges (BG-27/BG-28). */
	public array $allowanceCharges = array();
}
