From 81e9c4ee3233e40d77f57721e4cdd81b1830b587 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Radek=20Bedn=C3=A1=C5=99?= Date: Fri, 27 Jan 2023 15:16:27 +0100 Subject: [PATCH] MAR-13730 - decimal VAT support --- CHANGELOG.md | 6 ++++++ src/Article/DTO/ProductRequest.php | 8 ++++---- src/Article/Entity/Product.php | 10 +++++----- src/MpApiClient.php | 2 +- src/Order/Entity/Item.php | 10 +++++----- 5 files changed, 21 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bff260e..ad7a982 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## 5.0.0 - 2023-01-19 + +### Changed + +- `vat` attribute in article and order item is float + ## 4.4.0 - 2022-10-03 ### Changed diff --git a/src/Article/DTO/ProductRequest.php b/src/Article/DTO/ProductRequest.php index 7579792..c0a3826 100644 --- a/src/Article/DTO/ProductRequest.php +++ b/src/Article/DTO/ProductRequest.php @@ -12,7 +12,7 @@ final class ProductRequest extends AbstractArticleRequest use JsonSerializeEntityTrait; private string $categoryId; - private int $vat; + private float $vat; private ?float $price = null; private VariantRequestIterator $variants; /** @@ -23,7 +23,7 @@ final class ProductRequest extends AbstractArticleRequest private ?string $brandId = null; private ?float $weeeFee = null; - public function __construct(string $id, string $title, string $shortDesc, string $longDesc, string $categoryId, int $vat, int $priority) + public function __construct(string $id, string $title, string $shortDesc, string $longDesc, string $categoryId, float $vat, int $priority) { parent::__construct($id, $title, $shortDesc, $longDesc, $priority); $this->categoryId = $categoryId; @@ -128,12 +128,12 @@ public function setCategoryId(string $categoryId): void $this->categoryId = $categoryId; } - public function getVat(): int + public function getVat(): float { return $this->vat; } - public function setVat(int $vat): void + public function setVat(float $vat): void { $this->vat = $vat; } diff --git a/src/Article/Entity/Product.php b/src/Article/Entity/Product.php index 489580c..28cdf98 100644 --- a/src/Article/Entity/Product.php +++ b/src/Article/Entity/Product.php @@ -19,7 +19,7 @@ final class Product extends AbstractArticle protected ProductStageEnum $stage; protected string $categoryId; - protected int $vat; + protected float $vat; protected VariantIterator $variants; /** * @var string[] @@ -44,7 +44,7 @@ final class Product extends AbstractArticle * @param float $price * @param ?float $fairPrice * @param float $purchasePrice - * @param int $vat + * @param float $vat * @param float $rrp * @param MediaIterator $media * @param PromotionIterator $promotions @@ -78,7 +78,7 @@ private function __construct( float $price, ?float $fairPrice, float $purchasePrice, - int $vat, + float $vat, float $rrp, MediaIterator $media, PromotionIterator $promotions, @@ -157,7 +157,7 @@ public static function createFromApi(array $data): self (float) $data['price'], isset($data['fair_price']) ? (float)$data['fair_price'] : null, (float) $data['purchase_price'], - (int) $data['vat'], + (float) $data['vat'], (float) $data['rrp'], MediaIterator::createFromApi($data['media']), PromotionIterator::createFromApi($data['promotions']), @@ -189,7 +189,7 @@ public function getCategoryId(): string return $this->categoryId; } - public function getVat(): int + public function getVat(): float { return $this->vat; } diff --git a/src/MpApiClient.php b/src/MpApiClient.php index 347122e..630bbbf 100644 --- a/src/MpApiClient.php +++ b/src/MpApiClient.php @@ -29,7 +29,7 @@ final class MpApiClient implements ClientInterface, MpApiClientInterface { const APP_NAME = 'mp-api-client'; - const APP_VERSION = '4.4.0'; + const APP_VERSION = '5.0.0'; private BrandClientInterface $brandClient; private CategoryClientInterface $categoryClient; diff --git a/src/Order/Entity/Item.php b/src/Order/Entity/Item.php index 96433d0..c316bcf 100644 --- a/src/Order/Entity/Item.php +++ b/src/Order/Entity/Item.php @@ -15,7 +15,7 @@ final class Item implements JsonSerializable private int $articleId; private int $quantity; private float $price; - private int $vat; + private float $vat; private ?float $commission; private string $title; /** @@ -28,12 +28,12 @@ final class Item implements JsonSerializable * @param int $articleId * @param int $quantity * @param float $price - * @param int $vat + * @param float $vat * @param float|null $commission * @param string $title * @param string[] $serialNumbers */ - private function __construct(string $id, int $articleId, int $quantity, float $price, int $vat, ?float $commission, string $title, array $serialNumbers) + private function __construct(string $id, int $articleId, int $quantity, float $price, float $vat, ?float $commission, string $title, array $serialNumbers) { $this->id = $id; $this->articleId = $articleId; @@ -57,7 +57,7 @@ public static function createFromApi(array $data): self (int) $data['article_id'], (int) $data['quantity'], (float) $data['price'], - (int) $data['vat'], + (float) $data['vat'], InputDataUtil::getNullableFloat($data, 'commission'), (string) $data['title'], $data['serial_numbers'], @@ -84,7 +84,7 @@ public function getPrice(): float return $this->price; } - public function getVat(): int + public function getVat(): float { return $this->vat; }