<?php

use app\libraries\CommonHelper;
use app\libraries\DateHelper;
use app\libraries\Tenants;

if (!defined('BASEPATH'))
	exit('No direct script access allowed');

class Invoicing_refund_model extends MY_Model
{

	public $short = "ir";
	public $table;
	public $tbl;

	public function __construct()
	{
		parent::__construct();
		$this->database = $this->getTenantNo();
		$this->tbl = 'invoicing_receipt_refund';
		$this->table = $this->tbl . ' ' . $this->short;
		$this->load->model('Invoicing_model');
	}

	public function add($id, $amountpaid, $mode)
	{
		if ($mode === 'invoice') {
			return $this->insertDB($this->database, $this->tbl, ['invoice_id' => $id, 'refund_amount' => $amountpaid]);
		} else { //receiptitem
			return $this->insertDB($this->database, $this->tbl, ['receipt_item_id' => $id, 'refund_amount' => $amountpaid]);
		}
	}
}
