private function formatFixedDiscountRows($row) { // only amountIncVat (i.e. amount) was specified: if (isset($row->amount) && !isset($row->vatPercent) && !isset($row->amountExVat)) { $this->newRows = array_merge($this->newRows, $this->formatFixedDiscountSpecifiedAsAmountIncVatOnly($row)); } // only amountExVat was specified: if (!isset($row->amount) && !isset($row->vatPercent) && isset($row->amountExVat)) { $this->newRows = array_merge($this->newRows, $this->formatFixedDiscountSpecifiedAsAmountExVatOnly($row)); } // amountIncVat (i.e. amount) and vatPercent is set, so we use that vatPercent: if (isset($row->amount) && isset($row->vatPercent) && !isset($row->amountExVat)) { $orderRow = new WebServiceSoap\SveaOrderRow(); if (isset($row->discountId)) { $orderRow->ArticleNumber = $row->discountId; } $orderRow->Description = $this->formatRowNameAndDescription($row); if (isset($row->unit)) { $orderRow->Unit = $row->unit; } $orderRow->DiscountPercent = 0; //no discount on discount $orderRow->NumberOfUnits = 1; //only one discount per row //calculate discount $vatRate = $row->vatPercent; $discountAtThisVatRateIncVat = $row->amount; // $discountAtThisVatRateExVat = // WebServiceRowFormatter::convertIncVatToExVat( $discountAtThisVatRateIncVat, $vatRate ); $orderRow->PricePerUnit = -1 * ($this->priceIncludingVat ? $discountAtThisVatRateIncVat : WebServiceRowFormatter::convertIncVatToExVat($row->amount, \Svea\Helper::bround($row->vatPercent))); $orderRow->VatPercent = $vatRate; $orderRow->PriceIncludingVat = $this->priceIncludingVat ? TRUE : FALSE; $this->newRows[] = $orderRow; } // amountExVat (i.e. amount) and vatPercent is set, so we use that vatPercent: if (!isset($row->amount) && isset($row->vatPercent) && isset($row->amountExVat)) { $orderRow = new WebServiceSoap\SveaOrderRow(); if (isset($row->discountId)) { $orderRow->ArticleNumber = $row->discountId; } $orderRow->Description = $this->formatRowNameAndDescription($row); if (isset($row->unit)) { $orderRow->Unit = $row->unit; } $orderRow->DiscountPercent = 0; //no discount on discount $orderRow->NumberOfUnits = 1; //only one discount per row //calculate discount $vatRate = $row->vatPercent; $discountAtThisVatRate = $this->priceIncludingVat ? WebServiceRowFormatter::convertExVatToIncVat($row->amountExVat, \Svea\Helper::bround($row->vatPercent)) : $row->amountExVat; $orderRow->PricePerUnit = -1 * $discountAtThisVatRate; $orderRow->VatPercent = $vatRate; $orderRow->PriceIncludingVat = $this->priceIncludingVat ? TRUE : FALSE; $this->newRows[] = $orderRow; } }