<?php

namespace App\Reports\Sources\SupplierInvoices;

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' => "general"],
		'invoiceId' =>							[ 'type' => 'numeric',		'dbDef' => "BIGINT UNSIGNED NOT NULL",				'cat' => "general"],
		'invoiceNumber' =>						[ 'type' => 'string',		'dbDef' => "VARCHAR(30) NOT NULL DEFAULT ''",		'cat' => "general"],
		'invoiceDate' =>						[ 'type' => 'date',			'dbDef' => "DATE NULL DEFAULT NULL",				'cat' => "general"],
		'invoiceDateYM' =>						[ 'type' => 'yearMonth',	'dbDef' => "DATE NULL DEFAULT NULL",				'cat' => "general"],
		'invoiceDateY' =>                		[ 'type' => 'year',			'dbDef' => "YEAR NULL DEFAULT NULL",				'cat' => "general"],
		'invoiceDueDate' =>              		[ 'type' => 'date',			'dbDef' => "DATE NULL DEFAULT NULL",				'cat' => "general"],
		'invoiceDueDateYM' =>            		[ 'type' => 'yearMonth',	'dbDef' => "DATE NULL DEFAULT NULL",				'cat' => "general"],
		'invoiceDueDateY' =>             		[ 'type' => 'year',			'dbDef' => "YEAR NULL DEFAULT NULL",				'cat' => "general"],
		'invoiceDueDays' =>              		[ 'type' => 'numeric',		'dbDef' => "SMALLINT NULL DEFAULT 0",				'cat' => "general"],
		'invoiceDuePassedDays' =>        		[ 'type' => 'numeric',		'dbDef' => "MEDIUMINT NOT NULL DEFAULT 0",			'cat' => "general"],
		'invoiceFulfillmentDate' =>             [ 'type' => 'date',			'dbDef' => "DATE NULL DEFAULT NULL",				'cat' => "general"],
		'invoiceEstPayDate' =>            		[ 'type' => 'date',			'dbDef' => "DATE NULL DEFAULT NULL",				'cat' => "general"],
		'invoiceLastPaymentDate' =>             [ 'type' => 'date',			'dbDef' => "DATE NULL DEFAULT NULL",				'cat' => "general"],
		'invoiceLastPaymentDocTypeCode' => 		[ 'type' => 'string',		'dbDef' => "VARCHAR(25) NOT NULL DEFAULT ''",		'cat' => "general"],
		'invoiceLastPaymentDocTypeName' => 		[ 'type' => 'string',		'dbDef' => "VARCHAR(50) NOT NULL DEFAULT ''",		'cat' => "general"],
		'invoiceLastPaymentDocId' => 			[ 'type' => 'numeric',		'dbDef' => "BIGINT UNSIGNED NOT NULL",				'cat' => "general"],
		'invoiceSeries' =>              		[ 'type' => 'string',		'dbDef' => "VARCHAR(30) NULL DEFAULT NULL",			'cat' => "general"],
		'invoiceStatusOpCode' =>             	[ 'type' => 'string',		'dbDef' => "ENUM('notConfirmed','confirmed') NOT NULL DEFAULT 'notConfirmed'",	'cat' => "general"],
		'invoiceStatusOpName' =>             	[ 'type' => 'string',		'dbDef' => "VARCHAR(20) NOT NULL DEFAULT ''",		'cat' => "general"],
		'invoiceStatusFinCode' =>            	[ 'type' => 'string',		'dbDef' => "ENUM('n','p','t','o') NOT NULL DEFAULT 'n'", 'cat' => "general"],
		'invoiceStatusFinName' =>            	[ 'type' => 'string',		'dbDef' => "VARCHAR(20) NOT NULL DEFAULT ''",		'cat' => "general"],
		'invoiceFormOfPaymentCode' =>       	[ 'type' => 'string',		'dbDef' => "VARCHAR(20) NOT NULL DEFAULT ''",		'cat' => "general"],
		'invoiceFormOfPaymentName' =>       	[ 'type' => 'string',		'dbDef' => "VARCHAR(20) NOT NULL DEFAULT ''",		'cat' => "general"],
		'invoiceBlocked' =>              		[ 'type' => 'boolean',		'dbDef' => "TINYINT UNSIGNED NOT NULL DEFAULT 0",	'cat' => "general"],
		'invoiceBlockable' =>              		[ 'type' => 'boolean',		'dbDef' => "TINYINT UNSIGNED NOT NULL DEFAULT '1'",	'cat' => "general"],
		'invoiceRemarks' =>              		[ 'type' => 'string',		'dbDef' => "TEXT NOT NULL", 						'cat' => "general"],
		'invoiceProcessedRemarks' =>     		[ 'type' => 'string',		'dbDef' => "TEXT NOT NULL",							'cat' => "general", 'disabled' => true, 'content' => 'remarks'],
		'invoiceComments' =>            		[ 'type' => 'string',		'dbDef' => "TEXT NOT NULL",							'cat' => "general"],

		'invoiceBase' =>            			[ 'type' => 'price',		'dbDef' => "DECIMAL(16,3) NOT NULL DEFAULT 0",		'cat' => "values", 'subtotals' => "invoiceCurrency"],
		'invoiceVat' =>            	 		 	[ 'type' => 'price',		'dbDef' => "DECIMAL(16,3) NOT NULL DEFAULT 0",		'cat' => "values", 'subtotals' => "invoiceCurrency"],
		'invoiceTotal' =>            			[ 'type' => 'price',		'dbDef' => "DECIMAL(16,3) NOT NULL DEFAULT 0",		'cat' => "values", 'subtotals' => "invoiceCurrency"],
		'invoicePayedValue' =>            	 	[ 'type' => 'price',		'dbDef' => "DECIMAL(21,8) NOT NULL DEFAULT 0",		'cat' => "values", 'subtotals' => "invoiceCurrency"],
		'invoiceCurrency' =>             		[ 'type' => 'string',		'dbDef' => "VARCHAR(3) NOT NULL DEFAULT ''",		'cat' => "values"],
		'invoiceDefCurrencyExchRate' => 		[ 'type' => 'price',		'dbDef' => "DECIMAL(15,8) NOT NULL DEFAULT 0",		'cat' => "values"],
		'invoiceWorkCurrencyExchRate' =>		[ 'type' => 'price',		'dbDef' => "DECIMAL(15,8) NOT NULL DEFAULT 0",		'cat' => "values"],
		'invoiceBaseDefCurr' =>         		[ 'type' => 'price',		'dbDef' => "DECIMAL(16,3) NOT NULL DEFAULT 0",		'cat' => "values", 'subtotals' => true],
		'invoiceVatDefCurr' =>          		[ 'type' => 'price',		'dbDef' => "DECIMAL(16,3) NOT NULL DEFAULT 0",		'cat' => "values", 'subtotals' => true],
		'invoiceTotalDefCurr' =>         		[ 'type' => 'price',		'dbDef' => "DECIMAL(16,3) NOT NULL DEFAULT 0",		'cat' => "values", 'subtotals' => true],
		'invoiceBaseWorkCurr' =>         		[ 'type' => 'price',		'dbDef' => "DECIMAL(16,3) NOT NULL DEFAULT 0",		'cat' => "values", 'subtotals' => true],
		'invoiceVatWorkCurr' =>        		 	[ 'type' => 'price',		'dbDef' => "DECIMAL(16,3) NOT NULL DEFAULT 0",		'cat' => "values", 'subtotals' => true],
		'invoiceTotalWorkCurr' =>       		[ 'type' => 'price',		'dbDef' => "DECIMAL(16,3) NOT NULL DEFAULT 0",		'cat' => "values", 'subtotals' => true],

		'userId' =>         					[ 'type' => 'numeric',		'dbDef' => "SMALLINT UNSIGNED NOT NULL DEFAULT 0",	'cat' => "userDetails"],
		'userName' =>      			     		[ 'type' => 'string',		'dbDef' => "VARCHAR(101) NOT NULL DEFAULT ''",		'cat' => "userDetails"],
		'userOfficeId' =>       				[ 'type' => 'numeric',		'dbDef' => "SMALLINT UNSIGNED NOT NULL DEFAULT 0",	'cat' => "userDetails"],
		'userOfficeName' =>     				[ 'type' => 'string',		'dbDef' => "VARCHAR(150) NOT NULL DEFAULT ''",		'cat' => "userDetails"],
		'userDepartmentId' =>   				[ 'type' => 'numeric',		'dbDef' => "SMALLINT UNSIGNED NOT NULL DEFAULT 0",	'cat' => "userDetails"],
		'userDepartmentName' => 		 		[ 'type' => 'string',		'dbDef' => "VARCHAR(100) NOT NULL DEFAULT ''",		'cat' => "userDetails"],
		'addUserId' =>      					[ 'type' => 'numeric',		'dbDef' => "SMALLINT UNSIGNED NOT NULL DEFAULT 0",	'cat' => "userDetails"],
		'addUserName' =>    			 		[ 'type' => 'string',		'dbDef' => "VARCHAR(101) NOT NULL DEFAULT ''",		'cat' => "userDetails"],
		'blockUserId' =>     		 	 		[ 'type' => 'numeric',		'dbDef' => "SMALLINT UNSIGNED NOT NULL DEFAULT 0",	'cat' => "userDetails"],
		'blockUserName' =>   			 		[ 'type' => 'string',		'dbDef' => "VARCHAR(101) NOT NULL DEFAULT ''",		'cat' => "userDetails"],

		'addTime' =>        					[ 'type' => 'datetime',		'dbDef' => "DATETIME NULL DEFAULT NULL",			'cat' => "operationTimes"],
		'blockTime' =>      					[ 'type' => 'datetime',		'dbDef' => "DATETIME NULL DEFAULT NULL",			'cat' => "operationTimes"],
		'lastUpdateTime' => 					[ 'type' => 'datetime',		'dbDef' => "DATETIME NULL DEFAULT NULL",			'cat' => "operationTimes"],
		'updatesCount' =>   					[ 'type' => 'numeric',		'dbDef' => "SMALLINT UNSIGNED NOT NULL DEFAULT 0",	'cat' => "operationTimes"],

		'supplierId'	=>						[ 'type' => 'numeric',		'dbDef' => "SMALLINT UNSIGNED NOT NULL DEFAULT 0",	'cat' => "supplierDetails"],
		'supplierAlias'	=>						[ 'type' => 'string',		'dbDef' => "VARCHAR(100) NOT NULL DEFAULT ''",     	'cat' => "supplierDetails"],
		'supplierName'	=>						[ 'type' => 'string',		'dbDef' => "VARCHAR(212) NOT NULL DEFAULT ''",     	'cat' => "supplierDetails"],
		'supplierTrustId'	=>					[ 'type' => 'numeric',		'dbDef' => "SMALLINT UNSIGNED NOT NULL DEFAULT 0",	'cat' => "supplierDetails"],
		'supplierTrustName'	=>					[ 'type' => 'string',		'dbDef' => "VARCHAR(100) NOT NULL DEFAULT ''",     	'cat' => "supplierDetails"],
		'supplierRegNo'	=>				 		[ 'type' => 'string',		'dbDef' => "VARCHAR(100) NOT NULL DEFAULT ''",     	'cat' => "supplierDetails"],
		'supplierFiscalCode'	=>				[ 'type' => 'string',		'dbDef' => "VARCHAR(100) NOT NULL DEFAULT ''",     	'cat' => "supplierDetails"],
		'supplierCountryCode'	=>				[ 'type' => 'string',		'dbDef' => "CHAR(2) NOT NULL DEFAULT ''",     		'cat' => "supplierDetails"],
		'supplierCountryName'	=>				[ 'type' => 'string',		'dbDef' => "VARCHAR(100) NOT NULL DEFAULT ''",     	'cat' => "supplierDetails"],
		'supplierCityId'	=>				 	[ 'type' => 'numeric',		'dbDef' => "MEDIUMINT UNSIGNED NOT NULL DEFAULT 0",	'cat' => "supplierDetails"],
		'supplierCityName' =>      			    [ 'type' => 'string',		'dbDef' => "VARCHAR(100) NOT NULL DEFAULT ''",		'cat' => "supplierDetails"],
		'supplierRemarks' =>              		[ 'type' => 'string',		'dbDef' => "TEXT NOT NULL",							'cat' => "supplierDetails"],
		'supplierProcessedRemarks' =>     		[ 'type' => 'string',		'dbDef' => "TEXT NOT NULL",                      	'cat' => "supplierDetails", 'disabled' => true, 'content' => 'remarks'],
	 	'supplierDuplicated'	=>				[ 'type' => 'boolean',		'dbDef' => "TINYINT UNSIGNED NOT NULL DEFAULT 0",	'cat' => "supplierDetails"],
	 	'supplierOriginalId'	=> 				[ 'type' => 'numeric',		'dbDef' => "MEDIUMINT UNSIGNED NOT NULL DEFAULT 0",	'cat' => "supplierDetails"],
	 	'supplierBankAccountId'	=> 				[ 'type' => 'numeric',		'dbDef' => "INT UNSIGNED NOT NULL DEFAULT 0",		'cat' => "supplierDetails"],
	 	'supplierBankAccountNumber' => 			[ 'type' => 'string',		'dbDef' => "VARCHAR(100) NOT NULL DEFAULT ''",		'cat' => "supplierDetails"],
	 	'supplierBankAccountBankId' => 			[ 'type' => 'numeric',		'dbDef' => "SMALLINT UNSIGNED NOT NULL DEFAULT 0",	'cat' => "supplierDetails"],
	 	'supplierBankAccountBankName' => 		[ 'type' => 'string',		'dbDef' => "VARCHAR(150) NOT NULL DEFAULT ''",		'cat' => "supplierDetails"],
	 	'supplierBankAccountBankOfficeId' => 	[ 'type' => 'numeric',		'dbDef' => "SMALLINT UNSIGNED NOT NULL DEFAULT 0",	'cat' => "supplierDetails"],
	 	'supplierBankAccountBankOfficeName' =>	[ 'type' => 'string',		'dbDef' => "VARCHAR(100) NOT NULL DEFAULT ''",		'cat' => "supplierDetails"],
	];

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

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

	/**
	 * The columns dependencies list.
	 * @var array
	 */
	protected array $columnsDependencies = [
		'userOfficeName'					=> ['userOfficeId'],
		'userDepartmentId' 					=> ['userId'],
		'userDepartmentName' 				=> ['userDepartmentId'],
		'invoiceFormOfPaymentName'			=> ['invoiceFormOfPaymentCode'],
		'invoiceStatusOpName'				=> ['invoiceStatusOpCode'],
		'invoiceStatusFinName'				=> ['invoiceStatusFinCode'],
		'userName'							=> ['userId'],
		'addUserName'						=> ['addUserId'],
		'blockUserName'						=> ['blockUserId'],

		'supplierTrustId'					=> ['supplierId'],
		'supplierTrustName'					=> ['supplierTrustId'],
		'supplierAlias'						=> ['supplierId'],
		'supplierName'						=> ['supplierId'],
		'supplierRegNo'						=> ['supplierId'],
		'supplierFiscalCode'				=> ['supplierId'],
		'supplierDuplicated'				=> ['supplierId'],
		'supplierRemarks'					=> ['supplierId'],
		'supplierProcessedRemarks'			=> ['supplierId'],
		'supplierCountryCode'				=> ['supplierId'],
		'supplierCityId'					=> ['supplierId'],

		'supplierCountryName'				=> ['supplierCountryCode'],
		'supplierCityName'					=> ['supplierCityId'],

	 	'supplierBankAccountNumber'			=> ['supplierOriginalId', 'supplierBankAccountId'],
	 	'supplierBankAccountBankId'			=> ['supplierOriginalId', 'supplierBankAccountId'],
	 	'supplierBankAccountBankName'		=> ['supplierOriginalId', 'supplierBankAccountId'],
	 	'supplierBankAccountBankOfficeId'	=> ['supplierOriginalId', 'supplierBankAccountId'],
	 	'supplierBankAccountBankOfficeName'	=> ['supplierOriginalId', 'supplierBankAccountId'],

		'invoiceLastPaymentDocTypeName'		=> ['invoiceLastPaymentDocTypeCode'],
	];


}