|
- <?php
-
- namespace Lc\CaracoleBundle\Solver\Credit;
-
- use Lc\CaracoleBundle\Model\Credit\CreditHistoryInterface;
-
- use Lc\CaracoleBundle\Model\Credit\CreditHistoryModel;
-
- use function Clue\StreamFilter\remove;
-
- class CreditHistorySolver
- {
- public static function getTypeChoices() :array
- {
- return[
- CreditHistoryModel::TYPE_CREDIT,
- CreditHistoryModel::TYPE_DEBIT,
- ];
- }
- public function getMeanPaymentInheritedLabel(CreditHistoryInterface $creditHistory): string
- {
- return 'entity.CreditHistory.fields.meanPaymentOptions.' . $this->getMeanPaymentInherited($creditHistory);
- }
-
- public function getAmountInherited(CreditHistoryInterface $creditHistory): float
- {
- if ($creditHistory->getOrderPayment() !== null) {
- return $creditHistory->getOrderPayment()->getAmount();
- } else {
- if ($creditHistory->getOrderRefund() !== null) {
- return $creditHistory->getOrderRefund()->getAmount();
- } else {
- return $creditHistory->getAmount();
- }
- }
- }
-
- public function getMeanPaymentInherited(CreditHistoryInterface $creditHistory): string
- {
- if ($creditHistory->getOrderPayment() !== null) {
- return $creditHistory->getOrderPayment()->getMeanPayment();
- } else {
- if ($creditHistory->getOrderRefund() !== null) {
- return $creditHistory->getOrderRefund()->getMeanPayment();
- } else {
- return $creditHistory->getMeanPayment();
- }
- }
- }
-
- public function getPaidAtInherited(CreditHistoryInterface $creditHistory): ?\DateTimeInterface
- {
- if ($creditHistory->getOrderPayment() !== null) {
- return $creditHistory->getOrderPayment()->getPaidAt();
- } else {
- if ($creditHistory->getOrderRefund() !== null) {
- return $creditHistory->getOrderRefund()->getPaidAt();
- } else {
- return $creditHistory->getPaidAt();
- }
- }
- }
-
- public function getReferenceInherited(CreditHistoryInterface $creditHistory): ?string
- {
- if ($creditHistory->getOrderPayment() !== null) {
- return $creditHistory->getOrderPayment()->getReference();
- } else {
- if ($creditHistory->getOrderRefund() !== null) {
- return $creditHistory->getOrderRefund()->getReference();
- } else {
- return $creditHistory->getReference();
- }
- }
- }
-
- public function getCommentInherited(CreditHistoryInterface $creditHistory): ?string
- {
- if ($creditHistory->getOrderPayment() !== null) {
- return $creditHistory->getOrderPayment()->getComment();
- } else {
- if ($creditHistory->getOrderRefund() !== null) {
- return $creditHistory->getOrderRefund()->getComment();
- } else {
- return $creditHistory->getComment();
- }
- }
- }
- }
|