-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a906e73
commit 6ddf1f9
Showing
8 changed files
with
127 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?php | ||
|
||
namespace Ibertrand\BankSync\Setup\Patch\Data; | ||
|
||
use Exception; | ||
use Ibertrand\BankSync\Model\Dunning; | ||
use Ibertrand\BankSync\Model\DunningRepository; | ||
use Ibertrand\BankSync\Model\ResourceModel\Dunning\CollectionFactory; | ||
use Ibertrand\BankSync\Setup\Patch\Schema\IsBanksynced as IsBanksyncedSchemaPatch; | ||
use Magento\Framework\Setup\Patch\DataPatchInterface; | ||
use Magento\Framework\Setup\Patch\PatchRevertableInterface; | ||
|
||
class DunningIsPaid implements DataPatchInterface, PatchRevertableInterface | ||
{ | ||
private CollectionFactory $dunningCollectionFactory; | ||
private DunningRepository $dunningRepository; | ||
|
||
|
||
/** | ||
* @param CollectionFactory $dunningCollectionFactory | ||
* @param DunningRepository $dunningRepository | ||
*/ | ||
public function __construct( | ||
CollectionFactory $dunningCollectionFactory, | ||
DunningRepository $dunningRepository, | ||
) { | ||
$this->dunningCollectionFactory = $dunningCollectionFactory; | ||
$this->dunningRepository = $dunningRepository; | ||
} | ||
|
||
/** | ||
* @return string[] | ||
*/ | ||
public static function getDependencies(): array | ||
{ | ||
return [ | ||
IsBanksyncedSchemaPatch::class, | ||
]; | ||
} | ||
|
||
/** | ||
* @return array|string[] | ||
*/ | ||
public function getAliases(): array | ||
{ | ||
return []; | ||
} | ||
|
||
/** | ||
* @return void | ||
*/ | ||
public function apply() | ||
{ | ||
$dunnings = $this->dunningCollectionFactory->create(); | ||
foreach ($dunnings as $dunning) { | ||
/** @var Dunning $dunning */ | ||
try { | ||
if ($dunning->updatePaidStatus()) { | ||
$this->dunningRepository->save($dunning); | ||
} | ||
} catch (Exception $e) { | ||
echo $e->getMessage(); | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* @return void | ||
*/ | ||
public function revert(): void | ||
{ | ||
// No revert | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<?xml version="1.0"?> | ||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd"> | ||
<module name="Ibertrand_BankSync" setup_version="0.0.17"> | ||
<module name="Ibertrand_BankSync" setup_version="0.0.18"> | ||
</module> | ||
</config> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters