<?php

declare( strict_types=1 );

namespace Brightfern\Inbound;

/**
 * A human-readable summary parsed out of an inbound UBL/CII document, shown in
 * the admin inbox and used for order/customer matching.
 */
final class InboundSummary {
	public string $invoiceNumber = '';
	public string $issueDate = '';
	public string $currency = '';
	public float $payableAmount = 0.0;
	public string $supplierName = '';
	public string $supplierVat = '';
	public string $supplierEndpoint = '';
	public string $buyerName = '';
	public string $buyerVat = '';
	public string $buyerReference = '';   // BT-10 — often our order reference.
	public string $orderReference = '';   // BT-13.
	public string $documentType = 'invoice';

	/** @return array<string,mixed> */
	public function toArray(): array {
		return array(
			'invoiceNumber'    => $this->invoiceNumber,
			'issueDate'        => $this->issueDate,
			'currency'         => $this->currency,
			'payableAmount'    => $this->payableAmount,
			'supplierName'     => $this->supplierName,
			'supplierVat'      => $this->supplierVat,
			'supplierEndpoint' => $this->supplierEndpoint,
			'buyerName'        => $this->buyerName,
			'buyerVat'         => $this->buyerVat,
			'buyerReference'   => $this->buyerReference,
			'orderReference'   => $this->orderReference,
			'documentType'     => $this->documentType,
		);
	}
}
