<?php

namespace App\ReportsData\ChangesQueue\Entity;

class DocumentSeries extends \App\ReportsData\ChangesQueue\GeneralAbstract
{

	/**
	 * Returns the original table name that stores the original rows.
	 * @return string
	 */
	protected function getOriginalDbTableName()
	{
		global $DBTDocumentsNumbers;
		return $DBTDocumentsNumbers;
	}


	/**
	 * Is skips 'increaseNumber' operations as these are very often called. If the series does not
	 * get its code or "deleted" flag set
	 * {@inheritDoc}
	 * @see \App\ReportsData\ChangesQueue\GeneralAbstract::stopByEntityDetails()
	 */
	protected function stopByEntityDetails(\App\Entity\GeneralAbstract $entity)
	{

		$entityFields = $entity->getFields();

		// stop for non code/status set and operation is not "deleted"
		if (!array_key_exists('code', $entityFields) and $entity->getOperation()!='delete') {
			return true;
		}
		return parent::stopByEntityDetails($entity);

	}

}

