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.

CreditHistorySolver.php 2.7KB

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