Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

CreditHistorySolver.php 3.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?php
  2. namespace Lc\CaracoleBundle\Solver\Credit;
  3. use Lc\CaracoleBundle\Model\Credit\CreditHistoryInterface;
  4. use Lc\CaracoleBundle\Model\Credit\CreditHistoryModel;
  5. use function Clue\StreamFilter\remove;
  6. class CreditHistorySolver
  7. {
  8. public static function getTypeChoices() :array
  9. {
  10. return[
  11. CreditHistoryModel::TYPE_CREDIT,
  12. CreditHistoryModel::TYPE_DEBIT,
  13. ];
  14. }
  15. public function getMeanPaymentInheritedLabel(CreditHistoryInterface $creditHistory): string
  16. {
  17. return 'entity.CreditHistory.fields.meanPaymentOptions.' . $this->getMeanPaymentInherited($creditHistory);
  18. }
  19. public function getAmountInherited(CreditHistoryInterface $creditHistory): float
  20. {
  21. if ($creditHistory->getOrderPayment() !== null) {
  22. return $creditHistory->getOrderPayment()->getAmount();
  23. } else {
  24. if ($creditHistory->getOrderRefund() !== null) {
  25. return $creditHistory->getOrderRefund()->getAmount();
  26. } else {
  27. return $creditHistory->getAmount();
  28. }
  29. }
  30. }
  31. public function getMeanPaymentInherited(CreditHistoryInterface $creditHistory): string
  32. {
  33. if ($creditHistory->getOrderPayment() !== null) {
  34. return $creditHistory->getOrderPayment()->getMeanPayment();
  35. } else {
  36. if ($creditHistory->getOrderRefund() !== null) {
  37. return $creditHistory->getOrderRefund()->getMeanPayment();
  38. } else {
  39. return $creditHistory->getMeanPayment();
  40. }
  41. }
  42. }
  43. public function getPaidAtInherited(CreditHistoryInterface $creditHistory): ?\DateTimeInterface
  44. {
  45. if ($creditHistory->getOrderPayment() !== null) {
  46. return $creditHistory->getOrderPayment()->getPaidAt();
  47. } else {
  48. if ($creditHistory->getOrderRefund() !== null) {
  49. return $creditHistory->getOrderRefund()->getPaidAt();
  50. } else {
  51. return $creditHistory->getPaidAt();
  52. }
  53. }
  54. }
  55. public function getReferenceInherited(CreditHistoryInterface $creditHistory): ?string
  56. {
  57. if ($creditHistory->getOrderPayment() !== null) {
  58. return $creditHistory->getOrderPayment()->getReference();
  59. } else {
  60. if ($creditHistory->getOrderRefund() !== null) {
  61. return $creditHistory->getOrderRefund()->getReference();
  62. } else {
  63. return $creditHistory->getReference();
  64. }
  65. }
  66. }
  67. public function getCommentInherited(CreditHistoryInterface $creditHistory): ?string
  68. {
  69. if ($creditHistory->getOrderPayment() !== null) {
  70. return $creditHistory->getOrderPayment()->getComment();
  71. } else {
  72. if ($creditHistory->getOrderRefund() !== null) {
  73. return $creditHistory->getOrderRefund()->getComment();
  74. } else {
  75. return $creditHistory->getComment();
  76. }
  77. }
  78. }
  79. }