where('date >=', $fromDate ) // ->where('date <=', $toDate ) // ->orderBy('date', 'DESC') // ->findAll(); // } public function getAllCreditNotes($fromDate, $toDate) { return $this->select('ip_credit_notes.*, ip_credit_notes_items.name as item_name') ->join('ip_credit_notes_items', 'ip_credit_notes.creditnote_id = ip_credit_notes_items.creditnote_id', 'left') ->where('ip_credit_notes.date >=', $fromDate) ->where('ip_credit_notes.date <=', $toDate) ->orderBy('ip_credit_notes.date', 'DESC') ->findAll(); } /** * Fetch a single credit note by ID */ public function getCreditNoteById($id) { return $this->where('creditnote_id', $id)->first(); } /** * Insert a new credit note */ public function createCreditNote($data) { return $this->insert($data); } /** * Update an existing credit note */ public function updateCreditNote($id, $data) { return $this->update($id, $data); } /** * Delete a credit note by ID */ public function deleteCreditNote($id) { return $this->delete($id); } }