/**
  * Update existing payment
  *
  * @param void
  * @return null
  */
 function edit()
 {
     if ($this->active_invoice->isNew()) {
         $this->httpError(HTTP_ERR_NOT_FOUND);
     }
     // if
     if ($this->active_invoice_payment->isNew()) {
         $this->httpError(HTTP_ERR_NOT_FOUND);
     }
     // if
     if (!$this->active_invoice_payment->canEdit($this->logged_user)) {
         $this->httpError(HTTP_ERR_FORBIDDEN);
     }
     // if
     $invoice_payment_data = $this->request->post('invoice_payment');
     if (!is_array($invoice_payment_data)) {
         $invoice_payment_data = array('amount' => $this->active_invoice_payment->getAmount(), 'paid_on' => $this->active_invoice_payment->getPaidOn(), 'comment' => $this->active_invoice_payment->getComment());
     }
     // if
     $this->smarty->assign('invoice_payment_data', $invoice_payment_data);
     if ($this->request->isSubmitted()) {
         db_begin_work();
         $old_amount = $this->active_invoice_payment->getAmount();
         $this->active_invoice_payment->setAttributes($invoice_payment_data);
         $this->active_invoice_payment->setAmount($old_amount);
         // don't allow overwrite
         $this->active_invoice_payment->setInvoiceId($this->active_invoice->getId());
         $save = $this->active_invoice_payment->save();
         if ($save && !is_error($save)) {
             db_commit();
             flash_success('Payment #:id has been updated', array('id' => $this->active_invoice_payment->getId()));
             $this->redirectToUrl($this->active_invoice->getViewUrl());
         } else {
             db_rollback();
             $this->smarty->assign('errors', $save);
         }
         // if
     }
     // if
 }