<?php

namespace App\Reports\Sources\CashingPaymentDocs;

class ColumnsManager extends \App\Reports\Sources\ColumnsManagerAbstract
{

	/**
	 * The definition of report source columns.
	 * @var array
	 */
	protected array $columnsCfg = [
		'currentRowIndex'		=> ['type' => 'numeric',    	'dbDef' => "INT UNSIGNED NOT NULL DEFAULT 0",         	'cat' => "docDetails"],
		'id' 					=> ['type' => 'numeric', 		'dbDef' => "BIGINT UNSIGNED NOT NULL AUTO_INCREMENT", 	'cat' => "docDetails"],
		'doc_id' 				=> ['type' => 'numeric', 		'dbDef' => "BIGINT UNSIGNED NOT NULL DEFAULT 0", 		'cat' => "docDetails"],
		'doc_isCash'			=> ['type' => 'boolean', 		'dbDef' => "TINYINT UNSIGNED NOT NULL DEFAULT 0", 		'cat' => "docDetails"],
		'doc_sourceCode' 		=> ['type' => 'string', 		'dbDef' => "VARCHAR(20) DEFAULT ''", 					'cat' => "docDetails"],
		'doc_sourceName' 		=> ['type' => 'string', 		'dbDef' => "VARCHAR(30) DEFAULT ''", 					'cat' => "docDetails"],
		'doc_categoryCode'		=> ['type' => 'string', 		'dbDef' => "VARCHAR(10) DEFAULT ''", 					'cat' => "docDetails"],
		'doc_categoryName'		=> ['type' => 'string', 		'dbDef' => "VARCHAR(20) DEFAULT ''", 					'cat' => "docDetails"],
		'doc_typeCode' 			=> ['type' => 'string', 		'dbDef' => "VARCHAR(20) DEFAULT ''", 					'cat' => "docDetails"],
		'doc_typeName' 			=> ['type' => 'string', 		'dbDef' => "VARCHAR(50) DEFAULT ''", 					'cat' => "docDetails"],
		'doc_number'			=> ['type' => 'string', 		'dbDef' => "VARCHAR(50) DEFAULT ''", 					'cat' => "docDetails"],
		'doc_seriesCode' 		=> ['type' => 'string', 		'dbDef' => "VARCHAR(50) DEFAULT ''", 					'cat' => "docDetails"],
		'doc_seriesId' 			=> ['type' => 'numeric', 		'dbDef' => "MEDIUMINT DEFAULT 0", 						'cat' => "docDetails"],
		'doc_date' 				=> ['type' => 'date', 			'dbDef' => "DATE NULL", 								'cat' => "docDetails"],
		'doc_dateYM' 			=> ['type' => 'yearMonth',		'dbDef' => "DATE NULL", 								'cat' => "docDetails"],
		'doc_dateY' 			=> ['type' => 'year', 			'dbDef' => "YEAR NULL", 								'cat' => "docDetails"],
		'doc_value' 			=> ['type' => 'price', 			'dbDef' => "DECIMAL(16,3) NOT NULL DEFAULT 0", 			'cat' => "docDetails"],
		'doc_valueDefCurr' 		=> ['type' => 'price', 			'dbDef' => "DECIMAL(16,3) NOT NULL DEFAULT 0", 			'cat' => "docDetails"],
		'doc_valueWorkCurr' 	=> ['type' => 'price', 			'dbDef' => "DECIMAL(16,3) NOT NULL DEFAULT 0", 			'cat' => "docDetails"],
		'doc_currency' 			=> ['type' => 'string', 		'dbDef' => "VARCHAR(3) NOT NULL DEFAULT ''", 			'cat' => "docDetails"],
		'doc_currencyRate' 		=> ['type' => 'price', 			'dbDef' => "DECIMAL(15,8) NOT NULL DEFAULT 0", 			'cat' => "docDetails"],
		'doc_workCurrencyRate' 	=> ['type' => 'price', 			'dbDef' => "DECIMAL(15,8) NOT NULL DEFAULT 0", 			'cat' => "docDetails"],
		'doc_explanations'		=> ['type' => 'string', 		'dbDef' => "VARCHAR(100) DEFAULT ''", 					'cat' => "docDetails"],
		'doc_comments' 			=> ['type' => 'string', 		'dbDef' => "VARCHAR(100) DEFAULT ''", 					'cat' => "docDetails"],
		'doc_bankAccountId' 	=> ['type' => 'numeric', 		'dbDef' => "SMALLINT UNSIGNED DEFAULT 0", 				'cat' => "docDetails"],
		'doc_bankAccountNumber' => ['type' => 'string', 		'dbDef' => "VARCHAR(200) DEFAULT ''", 					'cat' => "docDetails"],

		'impDoc_id' 				=> ['type' => 'numeric', 	'dbDef' => "INT UNSIGNED NOT NULL DEFAULT 0",			'cat' => "impDocDetails"],
		'impDoc_value' 				=> ['type' => 'price', 		'dbDef' => "DECIMAL(16,3) NOT NULL DEFAULT 0", 			'cat' => "impDocDetails"],
		'impDoc_currency' 			=> ['type' => 'string', 	'dbDef' => "VARCHAR(3) NOT NULL DEFAULT ''", 			'cat' => "impDocDetails"],
		'impDoc_externalSystemId' 	=> ['type' => 'numeric',   	'dbDef' => "SMALLINT UNSIGNED NOT NULL DEFAULT 0",		'cat' => "impDocDetails"],
		'impDoc_externalSystemName'	=> ['type' => 'string',    	'dbDef' => "VARCHAR(50) NOT NULL DEFAULT ''",			'cat' => "impDocDetails"],
		'impDoc_systemStatusCode' 	=> ['type' => 'string',    	'dbDef' => "VARCHAR(10) NOT NULL DEFAULT ''",			'cat' => "impDocDetails"],
		'impDoc_processStatusCode' 	=> ['type' => 'string',    	'dbDef' => "VARCHAR(10) NOT NULL DEFAULT ''",			'cat' => "impDocDetails"],
		'impDoc_processStatusName' 	=> ['type' => 'string',    	'dbDef' => "VARCHAR(20) NOT NULL DEFAULT ''",			'cat' => "impDocDetails"],

		'inv_id' 				=> ['type' => 'numeric', 		'dbDef' => "BIGINT UNSIGNED NOT NULL DEFAULT 0", 		'cat' => "invoiceDetails"],
		'inv_number' 			=> ['type' => 'numeric', 		'dbDef' => "BIGINT UNSIGNED NOT NULL DEFAULT 0", 		'cat' => "invoiceDetails"],
		'inv_seriesId' 			=> ['type' => 'numeric', 		'dbDef' => "MEDIUMINT DEFAULT 0", 						'cat' => "invoiceDetails"],
		'inv_seriesCode' 		=> ['type' => 'string', 		'dbDef' => "VARCHAR(100) DEFAULT ''", 					'cat' => "invoiceDetails"],
		'inv_date' 				=> ['type' => 'date', 			'dbDef' => "DATE NULL DEFAULT NULL", 					'cat' => "invoiceDetails"],
		'inv_dueDate' 			=> ['type' => 'date', 			'dbDef' => "DATE NULL DEFAULT NULL", 					'cat' => "invoiceDetails"],
		'inv_value' 			=> ['type' => 'price', 			'dbDef' => "DECIMAL(16,3) NOT NULL DEFAULT 0", 			'cat' => "invoiceDetails"],
		'inv_vat' 				=> ['type' => 'price', 			'dbDef' => "DECIMAL(16,3) NOT NULL DEFAULT 0",	 		'cat' => "invoiceDetails"],
		'inv_total'				=> ['type' => 'price', 			'dbDef' => "DECIMAL(16,3) NOT NULL DEFAULT 0", 			'cat' => "invoiceDetails"],
		'inv_currency' 			=> ['type' => 'string', 		'dbDef' => "VARCHAR(3) NOT NULL DEFAULT ''", 			'cat' => "invoiceDetails"],

		'doc_partnerTypeCode' 	=> ['type' => 'string', 		'dbDef' => "VARCHAR(10) DEFAULT ''", 					'cat' => "partnerDetails"],
		'doc_partnerTypeName' 	=> ['type' => 'string', 		'dbDef' => "VARCHAR(20) DEFAULT ''", 					'cat' => "partnerDetails"],
		'doc_partnerName' 		=> ['type' => 'string', 		'dbDef' => "VARCHAR(100) DEFAULT ''", 					'cat' => "partnerDetails"],
		'inv_idCustomer' 		=> ['type' => 'numeric', 		'dbDef' => "INT DEFAULT 0", 							'cat' => "partnerDetails"],
		'inv_idCorporate' 		=> ['type' => 'numeric', 		'dbDef' => "INT DEFAULT 0", 							'cat' => "partnerDetails"],
		'inv_idSupplier' 		=> ['type' => 'numeric', 		'dbDef' => "MEDIUMINT DEFAULT 0", 						'cat' => "partnerDetails"],
		'doc_partnerId' 		=> ['type' => 'numeric', 		'dbDef' => "INT DEFAULT 0", 							'cat' => "partnerDetails"],

		'doc_respUserId' 		=> ['type' => 'numeric', 		'dbDef' => "SMALLINT DEFAULT 0", 						'cat' => "userDetails"],
		'doc_respUserName'		=> ['type' => 'string', 		'dbDef' => "VARCHAR(100) DEFAULT ''", 					'cat' => "userDetails"],
		'doc_respOfficeId'		=> ['type' => 'numeric', 		'dbDef' => "SMALLINT DEFAULT 0", 						'cat' => "userDetails"],
		'doc_respOfficeName'	=> ['type' => 'string', 		'dbDef' => "VARCHAR(100) DEFAULT ''", 					'cat' => "userDetails"],
		'doc_addUserId' 		=> ['type' => 'numeric', 		'dbDef' => "SMALLINT NOT NULL DEFAULT 0", 				'cat' => "userDetails"],
		'doc_addUserName' 		=> ['type' => 'string', 		'dbDef' => "VARCHAR(100) DEFAULT ''", 					'cat' => "userDetails"],
		'doc_addOfficeId' 		=> ['type' => 'numeric', 		'dbDef' => "SMALLINT NOT NULL DEFAULT 0", 				'cat' => "userDetails"],
		'doc_addOfficeName' 	=> ['type' => 'string', 		'dbDef' => "VARCHAR(100) DEFAULT ''", 					'cat' => "userDetails"],
		'doc_blockUserId' 		=> ['type' => 'numeric', 		'dbDef' => "SMALLINT DEFAULT 0", 						'cat' => "userDetails"],
		'doc_blockUserName' 	=> ['type' => 'string', 		'dbDef' => "VARCHAR(100) DEFAULT ''", 					'cat' => "userDetails"],
		'doc_issueUserId' 		=> ['type' => 'numeric', 		'dbDef' => "SMALLINT DEFAULT 0", 						'cat' => "userDetails"],
		'doc_issueUserName' 	=> ['type' => 'string', 		'dbDef' => "VARCHAR(100) DEFAULT ''", 					'cat' => "userDetails"],

		'doc_addTime' 			=> ['type' => 'datetime', 		'dbDef' => "DATETIME NULL",								'cat' => "operationTimes"],
		'doc_blockTime' 		=> ['type' => 'datetime', 		'dbDef' => "DATETIME NULL DEFAULT NULL",				'cat' => "operationTimes"],
		'doc_issueTime' 		=> ['type' => 'datetime', 		'dbDef' => "DATETIME NULL DEFAULT NULL",				'cat' => "operationTimes"],
	];

	/**
	 * The primary key column.
	 * @var string
	 */
	protected string $primaryKeyColumn = 'id';

	/**
	 * The columns that are forced into the report.
	 * @var array
	 */
	protected array $forcedColumns = [ 'doc_id' ];

	/**
	 * The columns dependencies list.
	 * @var array
	 */
	protected array $columnsDependencies = [
		'doc_sourceName' 			=> ['doc_sourceCode'],
		'doc_categoryName' 			=> ['doc_categoryCode'],
		'doc_typeName' 				=> ['doc_typeCode', 'doc_categoryCode', 'doc_sourceCode'],
		'doc_seriesCode'			=> ['doc_seriesId'],
		'doc_bankAccountNumber' 	=> ['doc_bankAccountId'],
		'doc_partnerId' 			=> ['inv_idCustomer', 'inv_idCorporate', 'inv_idSupplier'],
		'doc_partnerTypeName' 		=> ['doc_partnerTypeCode'],
		'doc_partnerName' 			=> ['inv_idCustomer', 'inv_idCorporate', 'inv_idSupplier', 'doc_partnerTypeCode'],
		'doc_respUserName' 			=> ['doc_respUserId'],
		'doc_respOfficeName' 		=> ['doc_respOfficeId'],
		'doc_addUserName' 			=> ['doc_addUserId'],
		'doc_addOfficeId' 			=> ['doc_addUserId'],
		'doc_addOfficeName' 		=> ['doc_addOfficeId'],
		'doc_blockUserName' 		=> ['doc_blockUserId'],
		'doc_issueUserName' 		=> ['doc_issueUserId'],

		'impDoc_externalSystemName'	=> ['impDoc_externalSystemId'],
		'impDoc_processStatusName'	=> ['impDoc_processStatusCode'],

		'inv_idCustomer'			=> ['inv_id'],
		'inv_idCorporate'			=> ['inv_id'],
		'inv_idSupplier'			=> ['inv_id'],
		'inv_seriesCode'			=> ['inv_seriesId'],
	];

}
