<?php

namespace App\Reports\Sources\InvoicePaymentDocs;

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"],
		'doc_id' 				=> ['type' => 'numeric',	'dbDef' => "BIGINT UNSIGNED NOT NULL DEFAULT 0", 	'cat' => "docDetails"],
		'doc_seriesId' 			=> ['type' => 'numeric',	'dbDef' => "MEDIUMINT UNSIGNED NOT NULL DEFAULT 0", 'cat' => "docDetails"],
		'doc_seriesCode' 		=> ['type' => 'string', 	'dbDef' => "VARCHAR(100) NOT NULL DEFAULT ''", 		'cat' => "docDetails"],
		'doc_typeCode' 			=> ['type' => 'string', 	'dbDef' => "VARCHAR(25) NOT NULL DEFAULT ''", 		'cat' => "docDetails"],
		'doc_typeName' 			=> ['type' => 'string', 	'dbDef' => "VARCHAR(50) NOT NULL DEFAULT ''", 		'cat' => "docDetails"],
		'doc_groupCode' 		=> ['type' => 'string', 	'dbDef' => "VARCHAR(10) NOT NULL DEFAULT ''", 		'cat' => "docDetails"],
		'doc_number' 			=> ['type' => 'string', 	'dbDef' => "VARCHAR(50) NOT NULL DEFAULT ''", 		'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_bankAccountId' 	=> ['type' => 'numeric', 	'dbDef' => "SMALLINT UNSIGNED NOT NULL DEFAULT 0", 	'cat' => "docDetails"],
		'doc_bankAccount'		=> ['type' => 'string', 	'dbDef' => "VARCHAR(200) NOT NULL DEFAULT ''", 		'cat' => "docDetails"],
		'doc_bankId' 			=> ['type' => 'numeric', 	'dbDef' => "SMALLINT UNSIGNED NOT NULL DEFAULT 0",	'cat' => "docDetails"],
		'doc_bankName' 			=> ['type' => 'string', 	'dbDef' => "VARCHAR(150) NOT NULL DEFAULT ''", 		'cat' => "docDetails"],
		'doc_explanations'		=> ['type' => 'string', 	'dbDef' => "TEXT NOT NULL ", 						'cat' => "docDetails"],
		'doc_comments' 			=> ['type' => 'string', 	'dbDef' => "TEXT NOT NULL ", 						'cat' => "docDetails"],
		'doc_remarks' 			=> ['type' => 'string', 	'dbDef' => "TEXT NOT NULL", 						'cat' => "docDetails"],
		'doc_processedRemarks' 	=> ['type' => 'string', 	'dbDef' => "TEXT NOT NULL",							'cat' => "docDetails", 'disabled' => true, 'content' => 'remarks'],

		'doc_value' 			=> ['type' => 'price',  'dbDef' => "DECIMAL(16,3) NOT NULL DEFAULT 0", 			'cat' => "docValues", 'subtotals' => "doc_currency"],
		'doc_valueDefCurr'		=> ['type' => 'price',  'dbDef' => "DECIMAL(16,3) NOT NULL DEFAULT 0", 			'cat' => "docValues", 'subtotals' => true],
		'doc_valueWorkCurr'		=> ['type' => 'price',  'dbDef' => "DECIMAL(16,3) NOT NULL DEFAULT 0", 			'cat' => "docValues", 'subtotals' => true],
		'doc_currency' 			=> ['type' => 'string', 'dbDef' => "VARCHAR(3) NOT NULL DEFAULT ''",			'cat' => "docValues"],
		'doc_currExchRate'		=> ['type' => 'price',  'dbDef' => "DECIMAL(15,8) NOT NULL DEFAULT 0", 			'cat' => "docValues"],
		'doc_workCurrExchRate'	=> ['type' => 'price',  'dbDef' => "DECIMAL(15,8) NOT NULL DEFAULT 0",		 	'cat' => "docValues"],
		'doc_invPayedValue'		=> ['type' => 'price',  'dbDef' => "DECIMAL(21,8) NOT NULL DEFAULT 0", 			'cat' => "docValues"],

		'doc_respUserId' 		=> ['type' => 'numeric', 'dbDef' => "SMALLINT UNSIGNED NOT NULL DEFAULT 0", 	'cat' => "docUserDetails"],
		'doc_respUserName' 		=> ['type' => 'string',  'dbDef' => "VARCHAR(101) NOT NULL DEFAULT ''", 		'cat' => "docUserDetails"],
		'doc_respOfficeId' 		=> ['type' => 'numeric', 'dbDef' => "SMALLINT UNSIGNED NOT NULL DEFAULT 0", 	'cat' => "docUserDetails"],
		'doc_respOfficeName' 	=> ['type' => 'string',  'dbDef' => "VARCHAR(150) NOT NULL DEFAULT ''", 		'cat' => "docUserDetails"],
		'doc_respDepartmentId'	=> ['type' => 'numeric', 'dbDef' => "SMALLINT UNSIGNED NOT NULL DEFAULT 0", 	'cat' => "docUserDetails"],
		'doc_respDepartmentName'=> ['type' => 'string',  'dbDef' => "VARCHAR(100) NOT NULL DEFAULT ''", 		'cat' => "docUserDetails"],
		'doc_addUserId' 		=> ['type' => 'numeric', 'dbDef' => "SMALLINT UNSIGNED NOT NULL DEFAULT 0", 	'cat' => "docUserDetails"],
		'doc_addUserName' 		=> ['type' => 'string',  'dbDef' => "VARCHAR(101) NOT NULL DEFAULT ''", 		'cat' => "docUserDetails"],
		'doc_updateUserId' 		=> ['type' => 'numeric', 'dbDef' => "SMALLINT UNSIGNED NOT NULL DEFAULT 0", 	'cat' => "docUserDetails"],
		'doc_updateUserName' 	=> ['type' => 'string',  'dbDef' => "VARCHAR(101) NOT NULL DEFAULT ''", 		'cat' => "docUserDetails"],
		'doc_blockUserId' 		=> ['type' => 'numeric', 'dbDef' => "SMALLINT UNSIGNED NOT NULL DEFAULT 0", 	'cat' => "docUserDetails"],
		'doc_blockUserName' 	=> ['type' => 'string',  'dbDef' => "VARCHAR(101) NOT NULL DEFAULT ''", 		'cat' => "docUserDetails"],

		'doc_addTime' 			=> ['type' => 'datetime', 'dbDef' => "DATETIME NULL", 		  			 		'cat' => "docOperationTimes"],
		'doc_updateTime' 		=> ['type' => 'datetime', 'dbDef' => "DATETIME NULL DEFAULT NULL",				'cat' => "docOperationTimes"],
		'doc_blockTime' 		=> ['type' => 'datetime', 'dbDef' => "DATETIME NULL DEFAULT NULL",				'cat' => "docOperationTimes"],

		'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", 'subtotals' => "impDoc_currency"],
		'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' => "invDetails"],
		'inv_supplierId'			=> ['type' => 'numeric', 	'dbDef' => "SMALLINT UNSIGNED NOT NULL DEFAULT 0", 						'cat' => "invDetails"],
		'inv_supplierName'			=> ['type' => 'string', 	'dbDef' => "VARCHAR(110) NOT NULL DEFAULT ''", 							'cat' => "invDetails"],
		'inv_supplierFiscalCode'	=> ['type' => 'string', 	'dbDef' => "VARCHAR(100) NOT NULL DEFAULT ''", 							'cat' => "invDetails"],
		'inv_supplierRegNo'			=> ['type' => 'string', 	'dbDef' => "VARCHAR(100) NOT NULL DEFAULT ''",							'cat' => "invDetails"],
		'inv_statusOpCode'			=> ['type' => 'string', 	'dbDef' => "ENUM('notConfirmed','confirmed','') NOT NULL DEFAULT ''",	'cat' => "invDetails"],
		'inv_statusOpName'			=> ['type' => 'string', 	'dbDef' => "VARCHAR(50) NOT NULL DEFAULT ''", 							'cat' => "invDetails"],
		'inv_statusFinCode'			=> ['type' => 'string', 	'dbDef' => "CHAR(1) NOT NULL DEFAULT ''", 								'cat' => "invDetails"],
		'inv_statusFinName'			=> ['type' => 'string', 	'dbDef' => "VARCHAR(50) NOT NULL DEFAULT ''", 							'cat' => "invDetails"],
		'inv_date'					=> ['type' => 'date', 		'dbDef' => "DATE NULL DEFAULT NULL", 									'cat' => "invDetails"],
		'inv_dateYM' 				=> ['type' => 'yearMonth',	'dbDef' => "DATE NULL DEFAULT NULL", 									'cat' => "invDetails"],
		'inv_dateY' 				=> ['type' => 'year', 		'dbDef' => "YEAR NULL DEFAULT NULL", 									'cat' => "invDetails"],
		'inv_dueDate'				=> ['type' => 'date', 		'dbDef' => "DATE NULL DEFAULT NULL", 									'cat' => "invDetails"],
		'inv_dueDateYM' 			=> ['type' => 'yearMonth',	'dbDef' => "DATE NULL DEFAULT NULL", 									'cat' => "invDetails"],
		'inv_dueDateY' 				=> ['type' => 'year', 		'dbDef' => "YEAR NULL DEFAULT NULL", 									'cat' => "invDetails"],
		'inv_series'				=> ['type' => 'string', 	'dbDef' => "VARCHAR(30) NOT NULL DEFAULT ''", 							'cat' => "invDetails"],
		'inv_number'				=> ['type' => 'string', 	'dbDef' => "VARCHAR(30) NOT NULL DEFAULT ''", 							'cat' => "invDetails"],
		'inv_comments'				=> ['type' => 'string', 	'dbDef' => "TEXT NOT NULL DEFAULT ''", 									'cat' => "invDetails"],
		'inv_remarks'				=> ['type' => 'string', 	'dbDef' => "TEXT NOT NULL DEFAULT ''", 									'cat' => "invDetails"],
		'inv_processedRemarks'		=> ['type' => 'string', 	'dbDef' => "TEXT NOT NULL DEFAULT ''", 									'cat' => "invDetails", 'disabled' => true, 'content' => 'remarks'],
		'inv_blocked'				=> ['type' => 'boolean', 	'dbDef' => "TINYINT UNSIGNED NOT NULL DEFAULT 0", 						'cat' => "invDetails"],
		'inv_addTime'				=> ['type' => 'datetime', 	'dbDef' => "DATETIME NULL", 											'cat' => "invDetails"],
		'inv_blockTime'				=> ['type' => 'datetime', 	'dbDef' => "DATETIME NULL DEFAULT NULL", 								'cat' => "invDetails"],

		'inv_priceValue'			=> ['type' => 'price', 	'dbDef' => "DECIMAL(16,3) NOT NULL DEFAULT 0", 		'cat' => "invValues", 'subtotals' => "inv_currency"],
		'inv_vatValue'				=> ['type' => 'price', 	'dbDef' => "DECIMAL(16,3) NOT NULL DEFAULT 0", 		'cat' => "invValues", 'subtotals' => "inv_currency"],
		'inv_totalValue'			=> ['type' => 'price', 	'dbDef' => "DECIMAL(16,3) NOT NULL DEFAULT 0", 		'cat' => "invValues", 'subtotals' => "inv_currency"],
		'inv_payedValue'			=> ['type' => 'price', 	'dbDef' => "DECIMAL(21,8) NOT NULL DEFAULT 0", 		'cat' => "invValues", 'subtotals' => "inv_currency"],
		'inv_currency'				=> ['type' => 'string', 'dbDef' => "VARCHAR(3) NOT NULL DEFAULT ''", 		'cat' => "invValues"],
		'inv_currExchRate' 			=> ['type' => 'price', 	'dbDef' => "DECIMAL(15,8) NOT NULL DEFAULT 0",		'cat' => "invValues"],
		'inv_workCurrExchRate'		=> ['type' => 'price', 	'dbDef' => "DECIMAL(15,8) NOT NULL DEFAULT 0",		'cat' => "invValues"],

		'inv_userId'			=> ['type' => 'numeric', 	'dbDef' => "SMALLINT UNSIGNED NOT NULL DEFAULT 0",	'cat' => "invUserDetails"],
		'inv_userName'			=> ['type' => 'string', 	'dbDef' => "VARCHAR(101) NOT NULL DEFAULT ''", 		'cat' => "invUserDetails"],
		'inv_officeId'			=> ['type' => 'numeric', 	'dbDef' => "SMALLINT UNSIGNED NOT NULL DEFAULT 0",	'cat' => "invUserDetails"],
		'inv_officeName'		=> ['type' => 'string', 	'dbDef' => "VARCHAR(150) NOT NULL DEFAULT ''", 		'cat' => "invUserDetails"],
		'inv_addUserId'			=> ['type' => 'numeric', 	'dbDef' => "SMALLINT UNSIGNED NOT NULL DEFAULT 0",	'cat' => "invUserDetails"],
		'inv_addUserName'		=> ['type' => 'string', 	'dbDef' => "VARCHAR(101) NOT NULL DEFAULT ''", 		'cat' => "invUserDetails"],
		'inv_blockUserId'		=> ['type' => 'numeric', 	'dbDef' => "SMALLINT UNSIGNED NOT NULL DEFAULT 0",	'cat' => "invUserDetails"],
		'inv_blockUserName'		=> ['type' => 'string', 	'dbDef' => "VARCHAR(101) NOT NULL DEFAULT ''", 		'cat' => "invUserDetails"],
	];

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

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

	/**
	 * The columns dependencies list.
	 * @var array
	 */
	protected array $columnsDependencies = [
		'doc_seriesCode' 				=> ['doc_seriesId'],
		'doc_typeName' 					=> ['doc_typeCode'],
		'doc_bankAccount'				=> ['doc_bankAccountId'],
		'doc_bankId'					=> ['doc_bankAccountId'],
		'doc_bankName'					=> ['doc_bankId'],

		'doc_respUserName'				=> ['doc_respUserId'],
		'doc_respOfficeName'			=> ['doc_respOfficeId'],
		'doc_respDepartmentName'		=> ['doc_respDepartmentId'],
		'doc_addUserName'				=> ['doc_addUserId'],
		'doc_updateUserName'			=> ['doc_updateUserId'],
		'doc_blockUserName'				=> ['doc_blockUserId'],

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

		'inv_supplierId'				=> ['inv_id'],
		'inv_supplierName' 				=> ['inv_supplierId'],
		'inv_supplierFiscalCode' 		=> ['inv_supplierId'],
		'inv_supplierRegNo' 			=> ['inv_supplierId'],

		'inv_statusOpName' 				=> ['inv_statusOpCode'],
		'inv_statusFinName' 			=> ['inv_statusFinCode'],

		'inv_userName' 					=> ['inv_userId'],
		'inv_officeName' 				=> ['inv_officeId'],
		'inv_addUserName' 				=> ['inv_addUserId'],
		'inv_blockUserName' 			=> ['inv_blockUserId'],
	];

}
