Skip to content

Commit

Permalink
added Vat to frontend API for product, transport and payment
Browse files Browse the repository at this point in the history
- also updated Convertim implementation
  • Loading branch information
TomasLudvik committed Dec 10, 2024
1 parent 3c0d0cb commit f0e5808
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/Model/Product/Elasticsearch/ProductExportRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ protected function getExportedFieldValue(int $domainId, Product $product, string
ProductExportFieldProvider::AVAILABLE_STORES_COUNT => $this->productAvailabilityFacade->getAvailableStoresCount($product, $domainId),
ProductExportFieldProvider::STORE_AVAILABILITIES_INFORMATION => $this->extractStoreAvailabilitiesInformation($product, $domainId),
ProductExportFieldProvider::AVAILABILITY_STATUS => $this->productAvailabilityFacade->getProductAvailabilityStatusByDomainId($product, $domainId),

ProductExportFieldProvider::VAT => $this->extractVat($product, $domainId),
default => throw new InvalidArgumentException(sprintf('There is no definition for exporting "%s" field to Elasticsearch', $field)),
};
}
Expand Down Expand Up @@ -513,4 +513,16 @@ protected function extractStoreAvailabilitiesInformation(Product $product, int $

return $result;
}

/**
* @param \Shopsys\FrameworkBundle\Model\Product\Product $product
* @param int $domainId
* @return array
*/
protected function extractVat(Product $product, int $domainId): array
{
return [
'percent' => $product->getVatForDomain($domainId)->getPercent(),
];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class ProductExportFieldProvider
public const string AVAILABLE_STORES_COUNT = 'available_stores_count';
public const string STORE_AVAILABILITIES_INFORMATION = 'store_availabilities_information';
public const string AVAILABILITY_STATUS = 'availability_status';
public const string VAT = 'vat';

/**
* @return string[]
Expand Down
2 changes: 2 additions & 0 deletions src/Model/Product/Search/ProductElasticsearchConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ public function fillEmptyFields(array $product): array
$result[ProductExportFieldProvider::UUID] = $product[ProductExportFieldProvider::UUID] ?? '00000000-0000-0000-0000-000000000000';
$result[ProductExportFieldProvider::UNIT] = $product[ProductExportFieldProvider::UNIT] ?? '';

$result['vat'] = $product['vat'] ?? ['percent' => '0'];

return $result;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public function testFillEmptyFields(): void
'stock_quantity' => null,
'uuid' => '00000000-0000-0000-0000-000000000000',
'unit' => '',
'vat' => ['percent' => '0'],
];

$converter = new ProductElasticsearchConverter();
Expand Down Expand Up @@ -138,6 +139,7 @@ public function testFillEmptyParameterFields(): void
'stock_quantity' => null,
'uuid' => '00000000-0000-0000-0000-000000000000',
'unit' => '',
'vat' => ['percent' => '0'],
];

$converter = new ProductElasticsearchConverter();
Expand Down

0 comments on commit f0e5808

Please sign in to comment.