getType(), [ CreditHistory::TYPE_DEBIT, CreditHistory::TYPE_PAYMENT, ]); } public function isTypeCredit(CreditHistory $creditHistory): bool { return in_array($creditHistory->getType(), [ CreditHistory::TYPE_CREDIT, CreditHistory::TYPE_INITIAL_CREDIT, CreditHistory::TYPE_REFUND ]); } public function getAmount(CreditHistory $creditHistory, bool $format = false): string { if ($format) { return number_format($creditHistory->getAmount(), 2) . ' €'; } else { return $creditHistory->getAmount(); } } /** * Retourne le libellé du CreditHistory informant de son type et * éventuellement de la date de sa commande associée. * */ public function getStrWording(CreditHistory $creditHistory): string { $str = ''; $type = $creditHistory->getType(); if (CreditHistory::TYPE_INITIAL_CREDIT == $type) { $str = 'Crédit initial'; } elseif (CreditHistory::TYPE_CREDIT == $type) { $str = 'Crédit'; } elseif (CreditHistory::TYPE_PAYMENT == $type) { $str = 'Paiement'; } elseif (CreditHistory::TYPE_REFUND == $type) { $str = 'Remboursement'; } elseif (CreditHistory::TYPE_DEBIT == $type) { $str = 'Débit'; } if (CreditHistory::TYPE_PAYMENT == $type || CreditHistory::TYPE_REFUND == $type) { $order = $creditHistory->getOrderObject(); if ($order && $order->distribution) { $str .= '
Commande : ' . date('d/m/Y', strtotime($order->distribution->date)); } else { $str .= '
Commande supprimée'; } } return $str; } public function getDate(CreditHistory $creditHistory, bool $format = false): string { $date = $creditHistory->getDate(); if ($format) { return date('d/m/Y à H:i:s', strtotime($date)); } else { return $date; } } public function getStrMeanPayment(CreditHistory $creditHistory): string { return MeanPayment::getStrBy($creditHistory->getMeanPayment()); } // strUserAction public function getStrUserAction(CreditHistory $creditHistory): string { $userAction = $creditHistory->getUserActionObject(); if ($userAction) { return $userAction->getName() . ' ' . $userAction->getlastname(); } else { return 'Système'; } } }