<?php defined('BASEPATH') OR exit('No direct script access allowed');

require_once APPPATH . 'processors/Transaction_processor.php';

class Material_processor extends Transaction_processor
{

/*
	public function __construct(&$params)
	{
		parent::__construct($params);
		// $this->ci =& get_instance();
	}

	public function init_save(&$postData)
	{
		parent::init_save($postData);

	}
*/
	public function pre_save(&$postData)
	{
		$postData["taxableAmount"] = 0;
		$postData["totAmount"] = 0;
		$postData["totTax"] = 0;
		$postData["dueAmount"] = 0;
		$postData["roundAmount"] = 0;
		$postData["totDisc"] = 0;
		$postData["totDiscItem"] = 0;
		$postData["payTotAmount"] = 0;
		$postData["chargableAmount"] = 0;
		$postData["subTotalAmount"] = 0;

		foreach($postData["details"] as &$val)
		{
			$val["locId"] = $postData["conId"];

			$val["rate"] = 0;
			$val["taxableAmount"] = 0;
			$val["taxId"] = 0;
			$val["itemTotal"] = 0;
			$val["chargesAmount"] = 0;
			$val["rateWithTax"] = 0;
			$val["unitRate"] = 0;
			$val["taxValue"] = 0;
			unset($val["tax"]);
		}

		unset($postData["payModes"]);
		unset($postData["couponAcc"]);
		unset($postData["tax"]);
		unset($postData["trans_payment"]);
		unset($postData["purcharges"]);
		unset($postData["totDisc"]);

		parent::pre_save($postData);
	}

	public function post_save(&$postData, &$result)
	{
		parent::post_save($postData, $result);
	}

	public function determine_category_code(&$data)
	{
		parent::determine_category_code($data);

		$data['categoryCode'] = 'MD';
		/*
		if (in_array($data['tType'], array(DELCHALLAN,PURRECP))  && !$this->params->isFranchise && $this->params->isMaterial)
		{
			$data['categoryCode'] = 'MD';
		}
		*/
	}
}
