Ejemplo n.º 1
0
 /**
  * Creating a payment for creditNote
  *
  * @param CreditNote    $creditNote
  * @param PaymentMethod $method
  * @param string        $value
  * @param string        $comments
  *
  * @return Ambigous <BaseEntityAbstract, GenericDAO>
  */
 public static function createFromCreditNote(CreditNote &$creditNote, PaymentMethod $method, $value, $comments = '', $paymentDate = '')
 {
     $payment = new Payment();
     $message = 'A ' . StringUtilsAbstract::getCurrency($value) . ' Credit Payment is made via ' . $method->getName() . ' for CreditNote(CreditNoteNo.=' . $creditNote->getCreditNoteNo() . ')' . (trim($comments) !== '' ? ': ' . $comments : '.');
     $payment = $payment->setCreditNote($creditNote)->setMethod($method)->setValue($value)->setPaymentDate(new UDate(trim($paymentDate) === '' ? 'now' : trim($paymentDate)))->save()->addComment($message, Comments::TYPE_ACCOUNTING)->addLog($message, Log::TYPE_SYSTEM, get_class($payment) . '_CREATION', __CLASS__ . '::' . __FUNCTION__);
     $creditNote->addComment($message, Comments::TYPE_ACCOUNTING)->addLog($message, Log::TYPE_SYSTEM, 'Auto Log', __CLASS__ . '::' . __FUNCTION__);
     return $payment;
 }