You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
- <?php
-
- namespace common\logic\User\CreditHistory;
-
- use common\logic\BaseService;
- use common\logic\BuilderInterface;
- use common\logic\User\UserProducer\UserProducerBuilder;
-
- class CreditHistoryBuilder extends BaseService implements BuilderInterface
- {
- protected CreditHistorySolver $creditHistorySolver;
- protected UserProducerBuilder $userProducerBuilder;
-
- public function __construct()
- {
- $this->creditHistorySolver = $this->loadService(CreditHistorySolver::class);
- $this->userProducerBuilder = $this->loadService(UserProducerBuilder::class);
- }
-
- public function save(CreditHistoryModel $creditHistory): bool
- {
- if ($creditHistory->getAmount() > -0.01 && $creditHistory->getAmount() < 0.01) {
- return false;
- }
-
- // Initialisation du commentaire avant sauvegarde
- $creditHistory->setComment($creditHistory->getComment() . $this->creditHistorySolver->getStrComment($creditHistory));
-
- $creditHistory->save();
-
- // Mise à jour du crédit au niveau de UserProducer
- $this->userProducerBuilder->updateCredit($creditHistory);
-
- return true;
- }
- }
|