TVA facturée, par taux en centièmes de % (négative pour un remboursement). */ public $taxes; /** * @param string $kind Type de ligne. * @param string|null $category Catégorie, ou null. * @param Amount $net Montant HT après remises. * @param array $taxes TVA par taux. */ public function __construct( string $kind, ?string $category, Amount $net, array $taxes = array() ) { $this->kind = $kind; $this->category = $category; $this->net = $net; $this->taxes = $taxes; } /** Raccourci pour les tests et l'adaptateur : montants décimaux, taux en %. */ public static function make( string $kind, ?string $category, $net, array $taxesByPercent = array() ): self { $taxes = array(); foreach ( $taxesByPercent as $percent => $tax ) { $rate = VatRate::fromPercent( $percent ); $taxes[ $rate ] = isset( $taxes[ $rate ] ) ? $taxes[ $rate ]->add( Amount::fromDecimal( $tax ) ) : Amount::fromDecimal( $tax ); } return new self( $kind, $category, Amount::fromDecimal( $net ), $taxes ); } public function taxTotal(): Amount { $sum = Amount::zero(); foreach ( $this->taxes as $tax ) { $sum = $sum->add( $tax ); } return $sum; } }