Example #1
0
 /**
  * Deletes an invoice and its associations
  * @return bool 
  */
 public function delete($delete_payments = true)
 {
     // get entries
     $Entry = new Entry();
     $Entry->delete_from_id($this->id);
     // get discounts
     $Discount = new Discount();
     $Discount->delete_from_id($this->id);
     // get payments
     if ($delete_payments) {
         $Payment = new Payment();
         $Payment->delete_from_id($this->id);
     }
     // update cache, see libraries/misc.php
     delete_cache_entry('invoices', $id);
     // get total
     return parent::delete();
 }
Example #2
0
 /**
  * Deletes a payment record; updates cache
  * @return bool 
  */
 public function delete()
 {
     $this->read();
     $id = $this->id;
     $invoice_id = $this->invoice_id;
     // delete
     parent::delete();
     // recalculate invoice total
     $invoice = new Invoice($invoice_id);
     $invoice->update_total();
     // update cache, see libraries/misc.php
     delete_cache_entry('payments', $id);
     // return
     return true;
 }