Skip to content

Commit

Permalink
Merge pull request #280 from OXID-eSales/b-7.0.x-remaining-balance-UN…
Browse files Browse the repository at this point in the history
…ZER-390

B 7.0.x remaining balance unzer 390
  • Loading branch information
mariolorenz authored Jun 7, 2024
2 parents d254c0d + f523b8c commit 0b42305
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- fix: PayPal sporadically fails on GHA CC Tests
- [0007638](https://bugs.oxid-esales.com/view.php?id=7638) - Fix: Sometimes duplicate order-positions in Backend, and dublicate ordermails ...
- refactor of the correct use of the appropriate credentials depending on the payment method used
- Show the remaining amount instead of the full amount in the transaction history if an order was e.g. partially collected

## [2.1.4] - 2023-11-23

Expand Down
37 changes: 37 additions & 0 deletions migration/data/Version20240524161420.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

declare(strict_types=1);

namespace OxidSolutionCatalysts\Unzer\Migrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Types\Types;
use Doctrine\Migrations\AbstractMigration;

/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20240524161420 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}

public function up(Schema $schema): void
{
$this->updateTransactionTable($schema);
}
protected function updateTransactionTable(Schema $schema): void
{
$transaction = $schema->getTable('oscunzertransaction');

if (!$transaction->hasColumn('REMAINING')) {
$transaction->addColumn('REMAINING', Types::FLOAT, ['default' => 0.0]);
}
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
}
}
9 changes: 9 additions & 0 deletions src/Model/Transaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,15 @@ public function getUnzerAmount(): ?string
return $this->getRawField('AMOUNT');
}

public function getUnzerRemaining(): ?string
{
if ($this->getUnzerState() === 'partly') {
return $this->getRawField('REMAINING');
}

return $this->getUnzerAmount();
}

/**
* @return string|null
*/
Expand Down
1 change: 1 addition & 0 deletions src/Service/Transaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ protected function getUnzerPaymentData(Payment $unzerPayment): array
);
$params = [
'amount' => $unzerPayment->getAmount()->getTotal(),
'remaining' => $unzerPayment->getAmount()->getRemaining(),
'currency' => $unzerPayment->getCurrency(),
'typeid' => $unzerPayment->getId(),
'oxaction' => $oxaction,
Expand Down
3 changes: 2 additions & 1 deletion tests/Unit/Service/TransactionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ public function testNotEmptyPaymentWriteTransactionToDB(): void
'oxaction' => 'statename',
'metadata' => 'metadataJson',
'customerid' => 'unzerCustomerId',
'customertype' => ''
'customertype' => '',
'remaining' => 0.0
]);

$this->assertTrue($sut->writeTransactionToDB("orderId", "userId", $payment));
Expand Down
2 changes: 1 addition & 1 deletion views/smarty/admin/tpl/oscunzer_order.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
<td>[{$oUnzerTransaction->getUnzerCustomerId()|escape}]</td>
<td>[{'OSCUNZER_TRANSACTION_STATUS_'|cat:$transaction_state|oxmultilangassign}]</td>
<td>[{$oUnzerTransaction->getUnzerTypeId()|escape}]</td>
<td>[{$oUnzerTransaction->getUnzerAmount()|string_format:"%.2f"}]
<td>[{$oUnzerTransaction->getUnzerRemaining()|string_format:"%.2f"}]
[{$oUnzerTransaction->getUnzerCurrency()}]
</td>
</tr>
Expand Down
2 changes: 1 addition & 1 deletion views/twig/admin/tpl/oscunzer_order.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
<td>{{ oUnzerTransaction.getUnzerCustomerId()|escape }}</td>
<td>{{ 'OSCUNZER_TRANSACTION_STATUS_'|cat(transaction_state)|translate }}</td>
<td>{{ oUnzerTransaction.getUnzerTypeId()|escape }}</td>
<td>{{ oUnzerTransaction.getUnzerAmount()|number_format(2, '.', ' ') }}
<td>{{ oUnzerTransaction.getUnzerRemaining()|number_format(2, '.', ' ') }}
{{ oUnzerTransaction.getUnzerCurrency() }}
</td>
</tr>
Expand Down

0 comments on commit 0b42305

Please sign in to comment.