Skip to content

Commit

Permalink
add system currency to config (#522)
Browse files Browse the repository at this point in the history
* add system currency to config

* add manufacturer external name as attribute
  • Loading branch information
Pfabeck authored Oct 15, 2019
1 parent ab09540 commit d291d14
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
<argument type="service" id="plenty_connector.logger" />
<argument type="service" id="plenty_connector.config_service" />
</service>

<service id="plentymarkets_adapter.helper.property" class="PlentymarketsAdapter\Helper\PropertyHelper"></service>

<!-- Request Generator -->
Expand Down Expand Up @@ -119,6 +119,8 @@

<service id="plentymarkets_adapter.request_generator.payment" class="PlentymarketsAdapter\RequestGenerator\Payment\PaymentRequestGenerator" public="false">
<argument type="service" id="plenty_connector.identity_service" />
<argument type="service" id="plenty_connector.config_service" />

</service>

<!-- Response Parser -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace PlentymarketsAdapter\RequestGenerator\Payment;

use PlentymarketsAdapter\PlentymarketsAdapter;
use SystemConnector\ConfigService\ConfigServiceInterface;
use SystemConnector\IdentityService\Exception\NotFoundException;
use SystemConnector\IdentityService\IdentityServiceInterface;
use SystemConnector\TransferObject\Currency\Currency;
Expand All @@ -16,9 +17,15 @@ class PaymentRequestGenerator implements PaymentRequestGeneratorInterface
*/
private $identityService;

public function __construct(IdentityServiceInterface $identityService)
/**
* @var ConfigServiceInterface
*/
private $configService;

public function __construct(IdentityServiceInterface $identityService, ConfigServiceInterface $configService)
{
$this->identityService = $identityService;
$this->configService = $configService;
}

/**
Expand Down Expand Up @@ -49,6 +56,12 @@ public function generate(Payment $payment): array
throw new NotFoundException('currency not mapped');
}

$isSystemCurrency = true;

if ($this->configService->get('system_currency') !== $currencyIdentity->getAdapterIdentifier()) {
$isSystemCurrency = false;
}

$paymentParams = [
'amount' => $payment->getAmount(),
'exchangeRatio' => 1,
Expand All @@ -57,6 +70,7 @@ public function generate(Payment $payment): array
'type' => 'credit',
'transactionType' => 2,
'status' => 2,
'isSystemCurrency' => $isSystemCurrency,
];

$paymentParams['properties'] = [
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
## [## [unreleased]]
### Added
- additional manufacturer information as attributes (@Pfabeck & @ugurkankya)
- set plentymarkets system currency for payments

## [## [5.3.2]]
### Fixed
Expand Down
7 changes: 5 additions & 2 deletions Resources/Views/backend/plenty_connector/model/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,11 @@ Ext.define('Shopware.apps.PlentyConnector.model.Settings', {
{
name: 'import_variations_without_stock',
type: 'boolean'
}
,
},
{
name: 'system_currency',
type: 'string'
},
{
name: 'amazon_pay_key',
type: 'string'
Expand Down
11 changes: 11 additions & 0 deletions Resources/Views/backend/plenty_connector/view/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,17 @@ Ext.define('Shopware.apps.PlentyConnector.view.Settings', {
anchor: '100%',
name: 'surcharge_as_product'
},
{
xtype: 'combobox',
fieldLabel: '{s name=plentyconnector/view/settings/system_currency/label}{/s}',
name: 'system_currency',
editable: false,
triggerAction: 'all',
selectOnFocus: true,
displayField: 'currency',
valueField: 'currency',
store: Ext.create('Shopware.apps.Base.store.Currency').load()
},
{
xtype: 'textfield',
fieldLabel: '{s name=plentyconnector/view/settings/amazon_pay_key}{/s}',
Expand Down
4 changes: 3 additions & 1 deletion Resources/snippets/backend/plentyconnector/main.ini
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ plentyconnector/view/actions/title = "Aktionen"
plentyconnector/view/actions/item_import = "Artikelabgleich"
plentyconnector/view/actions/item_import/item_id = "Plentymarkets Artikel-ID"
plentyconnector/view/settings/amazon_pay_key = "AmazonPay Key"
plentyconnector/view/settings/system_currency/label = "System Währung"

[en_GB]
plentyconnector/controller/mapping/loading = "Loading... (this may take some time)"
Expand Down Expand Up @@ -98,4 +99,5 @@ plentyconnector/view/settings/helperLink/text = "Find more options at the"
plentyconnector/view/actions/title = "Actions"
plentyconnector/view/actions/item_import = "Article Sync"
plentyconnector/view/actions/item_import/item_id = "Plentymarkets Article-ID"
plentyconnector/view/settings/amazon_pay_key = "AmazonPay Key"
plentyconnector/view/settings/amazon_pay_key = "AmazonPay Key"
plentyconnector/view/settings/system_currency/label = "System Currency"

0 comments on commit d291d14

Please sign in to comment.