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 Nov 7, 2024
1 parent 4593163 commit bbfc8a0
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/Model/Resolver/Payment/PaymentResolverMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ protected function map(): array
'goPayPaymentMethod' => function (Payment $payment) {
return $payment->getGoPayPaymentMethodByDomainId($this->domain->getId());
},
'vat' => function (Payment $payment) {
return $payment->getVatForDomain($this->domain->getId());
},
],
];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Overblog\DataLoader\DataLoaderInterface;
use Shopsys\FrameworkBundle\Component\Domain\Domain;
use Shopsys\FrameworkBundle\Model\Customer\User\CurrentCustomerUser;
use Shopsys\FrameworkBundle\Model\Pricing\Vat\Vat;
use Shopsys\FrameworkBundle\Model\Product\Accessory\ProductAccessoryFacade;
use Shopsys\FrameworkBundle\Model\Product\Availability\ProductAvailabilityFacade;
use Shopsys\FrameworkBundle\Model\Product\Collection\ProductCollectionFacade;
Expand Down Expand Up @@ -241,4 +242,13 @@ public function getProductType(Product $product): string
{
return $product->getProductType();
}

/**
* @param \Shopsys\FrameworkBundle\Model\Product\Product $product
* @return \Shopsys\FrameworkBundle\Model\Pricing\Vat\Vat
*/
public function getVat(Product $product): Vat
{
return $product->getVatForDomain($this->domain->getId());
}
}
6 changes: 6 additions & 0 deletions src/Model/Resolver/Transport/TransportResolverMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,19 @@
namespace Shopsys\FrontendApiBundle\Model\Resolver\Transport;

use Overblog\GraphQLBundle\Resolver\ResolverMap;
use Shopsys\FrameworkBundle\Component\Domain\Domain;
use Shopsys\FrameworkBundle\Model\Payment\PaymentFacade;
use Shopsys\FrameworkBundle\Model\Transport\Transport;

class TransportResolverMap extends ResolverMap
{
/**
* @param \Shopsys\FrameworkBundle\Model\Payment\PaymentFacade $paymentFacade
* @param \Shopsys\FrameworkBundle\Component\Domain\Domain $domain
*/
public function __construct(
protected readonly PaymentFacade $paymentFacade,
protected readonly Domain $domain,
) {
}

Expand All @@ -31,6 +34,9 @@ protected function map(): array
'transportTypeCode' => function (Transport $transport) {
return $transport->getType();
},
'vat' => function (Transport $transport) {
return $transport->getVatForDomain($this->domain->getId());
},
],
];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,5 @@ PaymentDecorator:
type:
type: "String!"
description: "Type of payment"
vat:
type: "Vat!"
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,5 @@ ProductDecorator:
type: "Boolean!"
productType:
type: "ProductTypeEnum!"
vat:
type: "Vat!"
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,5 @@ TransportDecorator:
transportTypeCode:
type: "TransportTypeEnum!"
description: "Code of transport type"
vat:
type: "Vat!"
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
VatDecorator:
type: object
decorator: true
config:
description: "Represents a vat"
fields:
name:
type: "String!"
description: "Vat name"
percent:
type: "String!"
description: "Vat percent"

0 comments on commit bbfc8a0

Please sign in to comment.