validate( $articleId, $surchargeDeliveryCosts, $surchargeCopperBaseStandard, $surchargeMaintenanceType, $copperNumberOption ); $this->copperSurchargeArticleId = $articleId; $this->surchargePositionType = $surchargePositionType; $this->surchargeDocumentConversion = $surchargeDocumentConversion; $this->surchargeInvoice = $surchargeInvoice; $this->surchargeDeliveryCosts = $surchargeDeliveryCosts; $this->surchargeCopperBase = $surchargeCopperBase; $this->surchargeCopperBaseStandard = $surchargeCopperBaseStandard; $this->copperNumberOption = $copperNumberOption; $this->surchargeMaintenanceType = $surchargeMaintenanceType; } /** * @param int $articleId * @param float $surchargeDeliveryCosts * @param float $surchargeCopperBaseStandard * * @param int $surchargeMaintenanceType * @param string $copperNumberOption */ private function validate( int $articleId, float $surchargeDeliveryCosts, float $surchargeCopperBaseStandard, int $surchargeMaintenanceType, string $copperNumberOption ) { if (empty($articleId)) { throw new ValidationFailedException('copper surcharge article is missing'); } if (empty($surchargeDeliveryCosts)) { throw new ValidationFailedException('surcharge delivery costs are missing'); } if (empty($surchargeCopperBaseStandard)) { throw new ValidationFailedException('surcharge copper base standard is missing'); } if ($surchargeMaintenanceType === self::SURCHARGE_MAINTENANCE_TYPE_ARTICLE && empty($copperNumberOption)) { throw new ValidationFailedException('copper number option is missing'); } } /** * @return int article id of the surcharge article */ public function getCopperSurchargeArticleId(): int { return $this->copperSurchargeArticleId; } /** * 0 = add always a surcharge position to every copper article, * 1 = add only one surcharge position for all copper articles, * 2 = add a surcharge position in every position group * * @return int */ public function getSurchargePositionType(): int { return $this->surchargePositionType; } /** * decides which date is the base if a surcharge positions is added to an order * 0 = date of offer (fallback current date) * 1 = date of the order * * @return int */ public function getSurchargeDocumentConversion(): int { return $this->surchargeDocumentConversion; } /** * decides which date is the base if a surcharge positions is added to an invoice * 0 = from the order (fallback current date) * 1 = delivery date (fallback current date) * 2 = from the invoice * 3 = from the offer (fallback current date) * * @return int */ public function getSurchargeInvoice(): int { return $this->surchargeInvoice; } /** * part of the calculation, default 1, in percent * * @return float */ public function getSurchargeDeliveryCosts(): float { return $this->surchargeDeliveryCosts; } /** * can be used instead of surchargeCopperBaseStandard for specific articles, EUR/100kg * * @return string */ public function getSurchargeCopperBase(): string { return $this->surchargeCopperBase; } /** * part of the the calculation, default 150, EUR/100kg * * @return float */ public function getSurchargeCopperBaseStandard(): float { return $this->surchargeCopperBaseStandard; } /** * describes which additional field in the article contains the weight, * only useful with surchargeMaintenanceType = 1 * * @return string */ public function getCopperNumberOption(): string { return $this->copperNumberOption; } /** * choice how copper articles should hold their necessary infos * 0 = with the app 'raw materials' * 1 = with additional article fields * * @return int */ public function getSurchargeMaintenanceType(): int { return $this->surchargeMaintenanceType; } }